コード例 #1
0
 public JObject GetScriptsSectionsTopics(string connectionString, int skillGroupId, int scriptId, int sectionId, int accountId, int mode)
 {
     try
     {
         DataAccessLayer.Scripts ScriptObj = new DataAccessLayer.Scripts(connectionString);
         System.Data.DataSet     ds        = ScriptObj.GetScriptsSectionsTopics(accountId, scriptId, sectionId, skillGroupId, mode);
         if (ds.IsNull())
         {
             _helper.CreateProperty(UDC.Label.SUCCESS, false);
             _helper.CreateProperty(UDC.Label.MESSAGE, ScriptObj.ErrorMessage);
         }
         else
         {
             _helper.ParseDataSet(ds);
         }
     }
     catch (Exception e)
     {
         Utilities.Logger.Error(e.ToString());
         _helper.InitializeResponseVariables();
         _helper.CreateProperty(UDC.Label.SUCCESS, false);
         _helper.CreateProperty(UDC.Label.MESSAGE, e.Message);
     }
     return(_helper.GetResponse());
 }
コード例 #2
0
 public JObject GetScripts(string connectionString, int accountId)
 {
     try
     {
         if (accountId == 0)
         {
             _helper.CreateProperty(UDC.Label.SUCCESS, false);
             _helper.CreateProperty(UDC.Label.MESSAGE, "AccountId is mandatory");
         }
         else
         {
             DataAccessLayer.Scripts ScriptObj = new DataAccessLayer.Scripts(connectionString);
             System.Data.DataSet     ds        = ScriptObj.GetScripts(accountId);
             if (ds == null)
             {
                 _helper.CreateProperty(UDC.Label.SUCCESS, false);
                 _helper.CreateProperty(UDC.Label.MESSAGE, ScriptObj.ErrorMessage);
             }
             else
             {
                 _helper.ParseDataSet(ds);
             }
         }
     }
     catch (Exception e)
     {
         Utilities.Logger.Error(e.ToString());
         _helper.InitializeResponseVariables();
         _helper.CreateProperty(UDC.Label.SUCCESS, false);
         _helper.CreateProperty(UDC.Label.MESSAGE, e.Message);
     }
     return(_helper.GetResponse());
 }
コード例 #3
0
        public JObject Create(string connectionString, string script, int accountId, int agentId)
        {
            try
            {
                JObject jsonObj = default(JObject);
                jsonObj = new JObject();
                jsonObj = JObject.Parse(script);
                string    scriptTitle   = jsonObj.SelectToken("ScriptTitle").ToString();
                int       skillGroupId  = Convert.ToInt32(jsonObj.SelectToken("SkillGroupId").ToString());
                int       check         = Convert.ToInt32(jsonObj.SelectToken("check").ToString());
                DataTable sectionsTable = new DataTable();
                sectionsTable.Columns.Add("Id", typeof(int));
                sectionsTable.Columns.Add("Name", typeof(string));
                DataTable topicsTable = new DataTable();
                topicsTable.Columns.Add("Title", typeof(string));
                topicsTable.Columns.Add("Description", typeof(string));
                topicsTable.Columns.Add("SectionId", typeof(int));
                JToken jUser     = jsonObj["Sections"];
                int    count     = jUser.Count();
                int    sectionId = 0;

                for (int i = 0; i < count; i++)
                {
                    sectionId = i + 1;
                    sectionsTable.Rows.Add(i + 1, jUser[i].SelectToken("sectionTitle").ToString());
                    JArray items       = (JArray)jUser[i].SelectToken("Topics");
                    int    topicsCount = items.Count();
                    for (int j = 0; j < topicsCount; j++)
                    {
                        string title       = items[j].SelectToken("Title").ToString();
                        string description = items[j].SelectToken("Description").ToString();
                        topicsTable.Rows.Add(title, description, sectionId);
                    }
                }



                DataAccessLayer.Scripts ScriptObj = new DataAccessLayer.Scripts(connectionString);
                System.Data.DataSet     ds        = ScriptObj.Create(scriptTitle, skillGroupId, check, sectionsTable, topicsTable, accountId, agentId);
                if (ds.IsNull())
                {
                    _helper.CreateProperty(UDC.Label.SUCCESS, false);
                    _helper.CreateProperty(UDC.Label.MESSAGE, ScriptObj.ErrorMessage);
                }
                else
                {
                    _helper.ParseDataSet(ds);
                }
            }
            catch (Exception e)
            {
                Utilities.Logger.Error(e.ToString());
                _helper.InitializeResponseVariables();
                _helper.CreateProperty(UDC.Label.SUCCESS, false);
                _helper.CreateProperty(UDC.Label.MESSAGE, e.Message);
            }
            return(_helper.GetResponse());
        }