当前位置: 首页>>代码示例>>C#>>正文


C# Utility.Decode方法代码示例

本文整理汇总了C#中Utility.Decode方法的典型用法代码示例。如果您正苦于以下问题:C# Utility.Decode方法的具体用法?C# Utility.Decode怎么用?C# Utility.Decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utility的用法示例。


在下文中一共展示了Utility.Decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: checkin

        public void checkin()
        {
            Utility settings = new Utility();
            HttpContext postedContext = HttpContext.Current;
            HttpFileCollection Files = postedContext.Request.Files;
            string serverKey = settings.Decode((string)postedContext.Request.Form["serverKey"]);

            if (serverKey == settings.GetSettings("Server Key"))
            {
                 string mac = settings.Decode((string)postedContext.Request.Form["mac"]);
                 string result = null;
                 try
                 {
                      using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                      {
                           NpgsqlCommand cmd = new NpgsqlCommand("client_checkin", conn);
                           cmd.CommandType = CommandType.StoredProcedure;
                           cmd.Parameters.Add(new NpgsqlParameter("@mac", mac));
                           conn.Open();
                           result = cmd.ExecuteScalar() as string;
                      }
                 }
                 catch (Exception ex)
                 {
                      result = "Could Not Check In.  Check The Exception Log For More Info";
                      Logger.Log(ex.ToString());
                 }
                 HttpContext.Current.Response.Write(result);
            }
            else
            {
                 Logger.Log("Incorrect Key For Client Checkin Was Provided");
            }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:34,代码来源:ClientSvc.asmx.cs

示例2: downloadimage

        public void downloadimage()
        {
            Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string partName = utility.Decode((string)postedContext.Request.Form["partName"]);
             string imageName = utility.Decode((string)postedContext.Request.Form["imgName"]);

             if (serverKey == utility.GetSettings("Server Key"))
             {

                  HttpContext.Current.Response.ContentType = "application/octet-stream";
                  HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + partName);
                  HttpContext.Current.Response.TransmitFile(utility.GetSettings("Image Store Path") + imageName + Path.DirectorySeparatorChar + partName);
                  HttpContext.Current.Response.End();
             }
             else
             {
                  Logger.Log("Provided Server Key Was Incorrect When Trying To Download Partition" + partName + " Key: " + serverKey);
             }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:23,代码来源:ClientSvc.asmx.cs

示例3: downloadcustomscripts

        public void downloadcustomscripts()
        {
            Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string scriptName = (string)postedContext.Request.Form["scriptName"];

             if (serverKey == utility.GetSettings("Server Key"))
             {
                  string scriptPath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "clientscripts" + Path.DirectorySeparatorChar;
                  HttpContext.Current.Response.ContentType = "application/octet-stream";
                  HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + scriptName);
                  HttpContext.Current.Response.TransmitFile(scriptPath + scriptName);
                  HttpContext.Current.Response.End();
             }
             Logger.Log("An Incorrect Key Was Provided While Trying To Download Custom Scripts");
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:19,代码来源:ClientSvc.asmx.cs

示例4: deleteimage

        public void deleteimage()
        {
            Host host = new Host();

             Image image = new Image();
             Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string imageName = utility.Decode((string)postedContext.Request.Form["imgName"]);

             if (serverKey == utility.GetSettings("Server Key"))
             {
                  if (!image.ImageProtected(imageName))
                  {
                       try
                       {
                            if (Directory.Exists(utility.GetSettings("Image Store Path") + imageName))
                                 utility.DeleteAllFiles(utility.GetSettings("Image Store Path") + imageName);

                            if (Directory.Exists(utility.GetSettings("Image Hold Path") + imageName))
                                 utility.DeleteAllFiles(utility.GetSettings("Image Hold Path") + imageName);
                       }
                       catch (Exception ex)
                       {
                            Logger.Log(ex.Message);
                            HttpContext.Current.Response.Write("Could Not Delete Existing Image");
                       }

                       try
                       {
                            if (utility.GetSettings("Image Transfer Mode") == "udp+http")
                                 Directory.CreateDirectory(utility.GetSettings("Image Store Path") + imageName);
                            else
                                 Directory.CreateDirectory(utility.GetSettings("Image Hold Path") + imageName);
                       }
                       catch (Exception ex)
                       {
                            Logger.Log(ex.Message);
                            HttpContext.Current.Response.Write("Could Not Delete Existing Image");
                       }
                       HttpContext.Current.Response.Write("true");
                  }
                  else
                       HttpContext.Current.Response.Write("Image Is Protected");
             }
             else
                  HttpContext.Current.Response.Write("Server Key Did Not Match");
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:50,代码来源:ClientSvc.asmx.cs

示例5: currentpos

        public void currentpos()
        {
            Utility settings = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;
             string mac = settings.Decode((string)postedContext.Request.Form["mac"]);

             string result = null;
             int tmpResult = 0;
             try
             {
                  using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                  {
                       NpgsqlCommand cmd = new NpgsqlCommand("client_hostsbeforeme", conn);
                       cmd.CommandType = CommandType.StoredProcedure;
                       cmd.Parameters.Add(new NpgsqlParameter("@mac", mac));
                       conn.Open();
                       tmpResult = Convert.ToInt16(cmd.ExecuteScalar());
                       result = tmpResult.ToString();

                  }
             }
             catch (Exception ex)
             {
                  result = "Could Not Get Current Queue Position.  Check The Exception Log For More Info";
                  Logger.Log(ex.ToString());
             }
             HttpContext.Current.Response.Write(result);
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:29,代码来源:ClientSvc.asmx.cs

示例6: upload

        public void upload()
        {
            Host host = new Host();
            Utility utility = new Utility();
            try
            {
                HttpContext postedContext = HttpContext.Current;
                HttpFileCollection Files = postedContext.Request.Files;

                string fileName = utility.Decode((string)postedContext.Request.Form["fileName"]);
                string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
                string imagePath = utility.Decode((string)postedContext.Request.Form["imagePath"]);
                string fileType = utility.Decode((string)postedContext.Request.Form["fileType"]);
                string fullPath = null;

                if (fileType == "mbr")
                {
                    imagePath = imagePath.Replace('/', Path.DirectorySeparatorChar);
                    if (utility.GetSettings("Image Transfer Mode") == "udp+http")
                        fullPath = utility.GetSettings("Image Store Path") + imagePath + Path.DirectorySeparatorChar + fileName;
                    else
                        fullPath = utility.GetSettings("Image Hold Path") + imagePath + Path.DirectorySeparatorChar + fileName;
                }
                else if (fileType == "log")
                    if (imagePath == "host")
                        fullPath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + "hosts" + Path.DirectorySeparatorChar + fileName;
                    else
                        fullPath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + fileName;
                else
                {
                    HttpContext.Current.Response.Write("File Type Not Specified");
                    return;
                }

                if (serverKey == utility.GetSettings("Server Key"))
                {
                        if (Files.Count == 1 && Files[0].ContentLength > 0 && fileName != null && fileName != "")
                        {
                            byte[] binaryWriteArray = new
                            byte[Files[0].InputStream.Length];
                            Files[0].InputStream.Read(binaryWriteArray, 0, (int)Files[0].InputStream.Length);
                            FileStream objfilestream = new FileStream(fullPath, FileMode.Create, FileAccess.ReadWrite);
                            objfilestream.Write(binaryWriteArray, 0, binaryWriteArray.Length);
                            objfilestream.Close();
                            if (File.Exists(fullPath))
                            {
                                FileInfo file = new FileInfo(fullPath);
                                if (file.Length > 0)
                                    HttpContext.Current.Response.Write("true");
                                else
                                    HttpContext.Current.Response.Write("File Has No Size");
                            }
                            else
                                HttpContext.Current.Response.Write("File Could Not Be Created");
                        }
                        else
                           HttpContext.Current.Response.Write("File Was Not Posted Successfully");
                }
                else
                    HttpContext.Current.Response.Write("Incorrect Server Key");
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                HttpContext.Current.Response.Write("Check The Exception Log For More Info");
            }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:67,代码来源:ClientSvc.asmx.cs

示例7: ucinfo

        public void ucinfo()
        {
            Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string direction = utility.Decode((string)postedContext.Request.Form["direction"]);
             string mac = utility.Decode((string)postedContext.Request.Form["mac"]);
             string imageID = utility.Decode((string)postedContext.Request.Form["imageID"]);

             if (utility.GetSettings("On Demand") == "Enabled")
             {
                 if (serverKey == utility.GetSettings("Server Key"))
                 {
                     Image image = new Image();
                     if (direction == "push")
                     {
                         if (!image.Check_Checksum(imageID))
                         {
                             HttpContext.Current.Response.Write("Client Error: This Image Has Not Been Confirmed And Cannot Be Deployed.");
                             return;
                         }
                     }

                     string storage = null;
                     string imageOS = null;
                     string hostName = null;
                     string hostScripts = null;
                     string hostArgs = null;
                     string serverIP = utility.GetSettings("Server IP");
                     string xferMode = utility.GetSettings("Image Transfer Mode");
                     string compAlg = utility.GetSettings("Compression Algorithm");
                     string compLevel = utility.GetSettings("Compression Level");
                     string imageProtected = null;
                     string imageName = null;
                     string result = null;
                     if (xferMode == "smb" || xferMode == "smb+http")
                         storage = utility.GetSettings("SMB Path");
                     else
                     {
                         if (direction == "pull")
                             storage = utility.GetSettings("Nfs Upload Path");
                         else
                             storage = utility.GetSettings("Nfs Deploy Path");
                     }
                     try
                     {
                         using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                         {
                             NpgsqlCommand cmd = new NpgsqlCommand("client_customunicastinfo", conn);
                             cmd.CommandType = CommandType.StoredProcedure;
                             cmd.Parameters.Add(new NpgsqlParameter("@imageName", imageID));
                             cmd.Parameters.Add(new NpgsqlParameter("@hostMac", mac));
                             cmd.Parameters.Add(new NpgsqlParameter("@imageOSResult", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@imageOSResult"].Direction = ParameterDirection.Output;
                             cmd.Parameters.Add(new NpgsqlParameter("@hostNameResult", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@hostNameResult"].Direction = ParameterDirection.Output;
                             cmd.Parameters.Add(new NpgsqlParameter("@hostscripts", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@hostscripts"].Direction = ParameterDirection.Output;
                             cmd.Parameters.Add(new NpgsqlParameter("@hostargs", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@hostargs"].Direction = ParameterDirection.Output;
                             cmd.Parameters.Add(new NpgsqlParameter("@imageprotected", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@imageprotected"].Direction = ParameterDirection.Output;
                             cmd.Parameters.Add(new NpgsqlParameter("@imagename", NpgsqlDbType.Varchar, 100));
                             cmd.Parameters["@imagename"].Direction = ParameterDirection.Output;

                             conn.Open();
                             cmd.ExecuteNonQuery();
                             imageOS = (cmd.Parameters["@imageOSResult"].Value as string);
                             hostName = (cmd.Parameters["@hostNameResult"].Value as string);
                             hostScripts = (cmd.Parameters["@hostscripts"].Value as string);
                             hostArgs = (cmd.Parameters["@hostargs"].Value as string);
                             imageProtected = (cmd.Parameters["@imageprotected"].Value as string);
                             imageName = (cmd.Parameters["@imagename"].Value as string);
                         }

                         result = "imgOS=" + imageOS + " imgName=" + imageName + " hostName=" + hostName + " hostScripts=" + "\"" + hostScripts + "\" " + hostArgs + " storage=" +
                             storage + " serverIP=" + serverIP + " xferMode=" + xferMode + " compAlg=" + compAlg + " compLevel=-" + compLevel + " imageProtected=" + imageProtected;

                         if (direction == "pull" && utility.GetSettings("Image Transfer Mode") == "udp+http")
                         {
                             Task task = new Task();
                             int portBase = task.GetPort();
                             result = result + " portBase=" + portBase;
                         }
                     }
                     catch (Exception ex)
                     {
                         result = "Client Error: Could Not Read Custom Unicast Info.  Check The Exception Log For More Info";
                         Logger.Log(ex.ToString());
                     }
                     HttpContext.Current.Response.Write(result);

                 }
                 else
                 {
                     Logger.Log("An Incorrect Key Was Provided While Trying To List Images");
                 }
             }
//.........这里部分代码省略.........
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:101,代码来源:ClientSvc.asmx.cs

示例8: imagesize

        public void imagesize()
        {
            Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;
             string imagename = utility.Decode((string)postedContext.Request.Form["imgName"]);
             string imagesize = utility.Decode((string)postedContext.Request.Form["imageSize"]);
            try
            {
                using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                {
                    NpgsqlCommand cmd = new NpgsqlCommand("images_updatesize", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new NpgsqlParameter("@imagename", imagename));
                    cmd.Parameters.Add(new NpgsqlParameter("@imagesize", imagesize));
                    conn.Open();
                    cmd.ExecuteNonQuery();

                }

            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                HttpContext.Current.Response.Write("false");
                return;
            }

            //Validate image specifications were recorded successfully
            Image image = new Image();
            image.ID = image.GetImageID(imagename);
            image.Read(image);
            Image_Physical_Specs existingips = new Image_Physical_Specs();
            try
            {
                existingips = JsonConvert.DeserializeObject<Image_Physical_Specs>(image.ClientSize);
            }
            catch(Exception ex)
            {
                Logger.Log(ex.ToString());
                HttpContext.Current.Response.Write("false");
                return;
            }
            if (existingips.hd == null)
            {
                HttpContext.Current.Response.Write("false");
                return;
            }
            //Reset Custom Specs
            image.UpdateSpecs(image.Name, "");
            HttpContext.Current.Response.Write("true");
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:52,代码来源:ClientSvc.asmx.cs

示例9: smbcredentials

        public void smbcredentials()
        {
            Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string credential = utility.Decode((string)postedContext.Request.Form["credential"]);
             string xferMode = utility.GetSettings("Image Transfer Mode");
             if (xferMode != "smb" && xferMode != "smb+http")
             {
                  Logger.Log("An Attempt Was Made To Access SMB Credentials But Current Image Transfer Mode Is Not SMB");
                  HttpContext.Current.Response.Write("");
                  HttpContext.Current.Response.End();
             }

             if (serverKey == utility.GetSettings("Server Key"))
             {
                if(credential == "username")
                     HttpContext.Current.Response.Write(utility.GetSettings("SMB User Name"));
                else if(credential == "password")
                     HttpContext.Current.Response.Write(utility.GetSettings("SMB Password"));
             }
             else
               Logger.Log("An Incorrect Key Was Provided While Trying To Access SMB Credentials");
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:26,代码来源:ClientSvc.asmx.cs

示例10: mcsessions

        public void mcsessions()
        {
            Utility utility = new Utility();
              HttpContext postedContext = HttpContext.Current;
              HttpFileCollection Files = postedContext.Request.Files;

              string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);

              if (utility.GetSettings("On Demand") == "Enabled")
              {
                   if (serverKey == utility.GetSettings("Server Key"))
                   {
                        string result = null;
                        var listSessions = new List<string>();
                        NpgsqlDataReader rdr = null;
                        try
                        {
                             using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                             {
                                  NpgsqlCommand cmd = new NpgsqlCommand("client_custommcsessions", conn);
                                  cmd.CommandType = CommandType.StoredProcedure;
                                  conn.Open();
                                  rdr = cmd.ExecuteReader();
                                  while (rdr.Read())
                                  {
                                       int n;
                                       bool isNumeric = int.TryParse((string)rdr["client_custommcsessions"], out n);
                                       if (isNumeric)
                                            listSessions.Add(n.ToString());
                                  }
                             }

                             if (listSessions.Count == 0)
                                  result = "There Are No Active Sessions";
                             else
                             {
                                  foreach (string session in listSessions)
                                       result += session + " ";
                             }
                        }
                        catch (Exception ex)
                        {
                             result = "Could Not Read Active Multicasts.  Check The Exception Log For More Info";
                             Logger.Log(ex.ToString());
                        }
                        HttpContext.Current.Session.Remove("Message");
                        HttpContext.Current.Response.Write(result);
                   }
                   else
                   {
                        Logger.Log("An Incorrect Key Was Provided While Trying To List Images");
                   }
              }
              else
              {
                   Logger.Log("On Demand Mode Is Globally Disabled.");
              }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:58,代码来源:ClientSvc.asmx.cs

示例11: mcinfo

        public void mcinfo()
        {
            Utility utility = new Utility();
              HttpContext postedContext = HttpContext.Current;
              HttpFileCollection Files = postedContext.Request.Files;

              string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
              string mcTaskName = utility.Decode((string)postedContext.Request.Form["mcTaskName"]);
              string mac = utility.Decode((string)postedContext.Request.Form["mac"]);

              if (utility.GetSettings("On Demand") == "Enabled")
              {
                   if (serverKey == utility.GetSettings("Server Key"))
                   {
                        string imageOS = null;
                        string imageName = null;
                        string hostName = null;
                        string portBase = null;
                        string result = null;
                        try
                        {
                             using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                             {
                                  NpgsqlCommand cmd = new NpgsqlCommand("client_custommcinfo", conn);
                                  cmd.CommandType = CommandType.StoredProcedure;
                                  cmd.Parameters.Add(new NpgsqlParameter("@mcTaskName", mcTaskName));
                                  cmd.Parameters.Add(new NpgsqlParameter("@hostMac", mac));
                                  cmd.Parameters.Add(new NpgsqlParameter("@imageOSResult", NpgsqlDbType.Varchar, 100));
                                  cmd.Parameters["@imageOSResult"].Direction = ParameterDirection.Output;
                                  cmd.Parameters.Add(new NpgsqlParameter("@imageNameResult", NpgsqlDbType.Varchar, 100));
                                  cmd.Parameters["@imageNameResult"].Direction = ParameterDirection.Output;
                                  cmd.Parameters.Add(new NpgsqlParameter("@hostNameResult", NpgsqlDbType.Varchar, 100));
                                  cmd.Parameters["@hostNameResult"].Direction = ParameterDirection.Output;
                                  cmd.Parameters.Add(new NpgsqlParameter("@portBaseResult", NpgsqlDbType.Varchar, 100));
                                  cmd.Parameters["@portBaseResult"].Direction = ParameterDirection.Output;
                                  conn.Open();
                                  cmd.ExecuteNonQuery();
                                  imageOS = (cmd.Parameters["@imageOSResult"].Value as string);
                                  hostName = (cmd.Parameters["@hostNameResult"].Value as string);
                                  portBase = (cmd.Parameters["@portBaseResult"].Value as string);
                                  imageName = (cmd.Parameters["@imageNameResult"].Value as string);
                                  result = "imgOS=" + imageOS + " portBase=" + portBase + " imgName=" + imageName;
                             }
                        }
                        catch (Exception ex)
                        {
                             result = "Could Not Read Multicast Info.  Check The Exception Log For More Info";
                             Logger.Log(ex.ToString());
                        }
                        HttpContext.Current.Response.Write(result);
                   }
                   else
                   {
                        Logger.Log("An Incorrect Key Was Provided While Trying To List Images");
                   }
              }
              else
              {
                   Logger.Log("On Demand Mode Is Globally Disabled.");
              }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:61,代码来源:ClientSvc.asmx.cs

示例12: mccheckout

        public void mccheckout()
        {
            Utility settings = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;
             string portBase = settings.Decode((string)postedContext.Request.Form["portBase"]);

            string result = null;
            string pid = null;
            try
            {
                using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                {
                    NpgsqlCommand cmd = new NpgsqlCommand("client_readmcpid", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new NpgsqlParameter("@portBase", portBase));
                    conn.Open();
                    pid = cmd.ExecuteScalar() as string;
                }
            }
            catch (Exception ex)
            {
                result = "Could Not Read Multicast PID.  Check The Exception Log For More Info";
                Logger.Log(ex.ToString());
            }

            if (pid != "0")
            {
                bool prsRunning = true;

                if (Environment.OSVersion.ToString().Contains("Unix"))
                {
                    try
                    {
                        Process prs = Process.GetProcessById(Convert.ToInt32(pid));
                        if (prs.HasExited)
                        {
                            prsRunning = false;
                        }
                    }
                    catch
                    {
                        prsRunning = false;
                    }

                }
                else
                {
                    try
                    {
                        Process prs = Process.GetProcessById(Convert.ToInt32(pid));
                    }
                    catch
                    {
                        prsRunning = false;
                    }
                }
                if (!prsRunning)
                {
                    try
                    {
                        using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                        {
                            NpgsqlCommand cmd = new NpgsqlCommand("client_closemc", conn);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new NpgsqlParameter("@portBase", portBase));
                            conn.Open();
                            cmd.ExecuteNonQuery();
                            result = "Success";
                        }
                    }
                    catch (Exception ex)
                    {
                        result = "An Error Has Occurred.  Check The Exception Log For More Info";
                        Logger.Log(ex.ToString());
                    }
                }
                else
                    result = "Cannot Close Session, It Is Still In Progress";
            }
            else
                result = "Session Is Already Closed";
            HttpContext.Current.Response.Write(result);
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:84,代码来源:ClientSvc.asmx.cs

示例13: listimages

        public void listimages()
        {
            Utility utility = new Utility();
              HttpContext postedContext = HttpContext.Current;
              HttpFileCollection Files = postedContext.Request.Files;

              string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);

              if (utility.GetSettings("On Demand") == "Enabled")
              {
                   if (serverKey == utility.GetSettings("Server Key"))
                   {
                        var listImages = new List<string>();
                        string result = null;
                        try
                        {
                             using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
                             {
                                  NpgsqlCommand cmd = new NpgsqlCommand("images_getimagescustom", conn);
                                  cmd.CommandType = CommandType.StoredProcedure;
                                  conn.Open();
                                  NpgsqlDataReader rdr = cmd.ExecuteReader();
                                  while (rdr.Read())
                                       listImages.Add(rdr["imageid"].ToString() + " " + (string)rdr["imagename"]);
                             }
                             foreach (string image in listImages)
                                  result += image + ",";
                        }
                        catch (Exception ex)
                        {
                             result = "Could Not Read Image List.  Check The Exception Log For More Info";
                             Logger.Log(ex.ToString());
                        }
                        HttpContext.Current.Response.Write(result);
                   }
                   else
                   {
                        Logger.Log("An Incorrect Key Was Provided While Trying To List Images " + serverKey );
                   }
              }
              else
              {
                   Logger.Log("On Demand Mode Is Globally Disabled.");
              }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:45,代码来源:ClientSvc.asmx.cs

示例14: consolelogin

        public void consolelogin()
        {
            History history = new History();
            Utility settings = new Utility();
            HttpContext postedContext = HttpContext.Current;
            HttpFileCollection Files = postedContext.Request.Files;

            string serverKey = settings.Decode((string)postedContext.Request.Form["serverKey"]);
            history.IP = settings.Decode((string)postedContext.Request.Form["clientIP"]);

            if (serverKey == settings.GetSettings("Server Key"))
            {
                 string username = settings.Decode((string)postedContext.Request.Form["username"]);
                 string password = settings.Decode((string)postedContext.Request.Form["password"]);
                 string task = settings.Decode((string)postedContext.Request.Form["task"]);

                 if (settings.UserLogin(username, password))
                 {
                      WDSUser wdsuser = new WDSUser();
                      string userID = wdsuser.GetID(username);
                      wdsuser.ID = userID;
                      wdsuser = wdsuser.Read(wdsuser);

                      if (task == "ond" && wdsuser.OndAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else if (task == "debug" && wdsuser.DebugAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else if (task == "diag" && wdsuser.DiagAccess == "1")
                      {
                           HttpContext.Current.Response.Write("true," + userID);
                           history.Event = "Successful Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.TypeID = userID;
                           history.Notes = "";
                           history.CreateEvent(history);
                      }
                      else
                      {
                           HttpContext.Current.Response.Write("false");
                           history.Event = "Failed Console Login";
                           history.Type = "User";
                           history.EventUser = username;
                           history.Notes = password;
                           history.CreateEvent(history);
                      }
                 }
                 else if (!string.IsNullOrEmpty(settings.GetSettings("AD Login Domain")))
                 {

                      try
                      {
                           PrincipalContext context = new PrincipalContext(ContextType.Domain, settings.GetSettings("AD Login Domain"), username, password);
                           UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, username);
                           if (user != null)
                           {
                                WDSUser wdsuser = new WDSUser();
                                string userID = wdsuser.GetID(username);
                                wdsuser.ID = userID;
                                wdsuser = wdsuser.Read(wdsuser);

                                if (task == "ond" && wdsuser.OndAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
                                     history.Event = "Successful Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.TypeID = userID;
                                     history.Notes = "";
                                     history.CreateEvent(history);
                                }
                                else if (task == "debug" && wdsuser.DebugAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
                                     history.Event = "Successful Console Login";
                                     history.Type = "User";
                                     history.EventUser = username;
                                     history.TypeID = userID;
                                     history.Notes = "";
                                     history.CreateEvent(history);
                                }
                                else if (task == "diag" && wdsuser.DiagAccess == "1")
                                {
                                     HttpContext.Current.Response.Write("true," + userID);
//.........这里部分代码省略.........
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:101,代码来源:ClientSvc.asmx.cs

示例15: getfilenames

        public void getfilenames()
        {
            Utility utility = new Utility();
            HttpContext postedContext = HttpContext.Current;
            HttpFileCollection Files = postedContext.Request.Files;

            string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);

            if (serverKey == utility.GetSettings("Server Key"))
            {
                 string imageName = utility.Decode((string)postedContext.Request.Form["imgName"]);
                 List<string> dirs = new List<string>();
                 string result = null;
                 string path = utility.GetSettings("Image Store Path") + imageName;
                 dirs.Add(path);

                 for (int x = 2; true; x++)
                 {
                      string subdir = path + Path.DirectorySeparatorChar + "hd" + x;
                      if (Directory.Exists(subdir))
                           dirs.Add(subdir);
                      else
                           break;
                 }

                 foreach (string dirPath in dirs)
                 {
                      var files = Directory.GetFiles(dirPath, "*.*");
                      foreach (var file in files)
                           result += Path.GetFileName(file) + ";";

                      result += ",";
                 }

                 HttpContext.Current.Response.Write(result);
            }
            else
            {
                 HttpContext.Current.Response.Write("false");
                 Logger.Log("Incorrect Key Provided for Client Getfilenames");
            }
        }
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:42,代码来源:ClientSvc.asmx.cs


注:本文中的Utility.Decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。