Пример #1
0
        /// <summary>
        /// Creates a local temporary file so that we can send it to the user
        /// TODO create something that will work better with Azure.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static object CreateTempScriptFile(Rootobject model)
        {
            var path = "ChockIS" + DateTime.Now.Ticks + ".ps1";

            using (var file = new StreamWriter(HttpRuntime.AppDomainAppPath + @"temp\" + path))
            {
                foreach (var package in model.packages)
                {
                    file.WriteLine("cinstm " + package.package);
                }
                file.Flush();
                file.Close();
            }

            return path;
        }
Пример #2
0
 public override List <User> extactData(Rootobject result)
 {
     return(result.users.ToList());
 }
Пример #3
0
        public ActionResult CreateComment(string Name, string EmailAddress, string Message, int id)
        {
            try
            {
                string filePath = Server.MapPath("~/App_Data/Blog-Posts.json");


                Comment comment = new Comment();
                //comment.id = Guid.NewGuid();
                comment.name         = Name;
                comment.emailAddress = EmailAddress;
                comment.message      = Message;
                comment.date         = DateTime.Now;

                //
                string json = string.Empty;
                using (StreamReader r = new StreamReader(filePath))
                {
                    json = r.ReadToEnd();
                }
                Rootobject list = JsonConvert.DeserializeObject <Rootobject>(json);



                try
                {
                    var newBlogPostComments = list.blogPosts.Where(b => b.id == id).FirstOrDefault().comments;
                    if (newBlogPostComments != null)
                    {
                        newBlogPostComments.Add(comment);
                    }
                    else
                    {
                        List <Comment> newList = new List <Comment>();

                        newList.Add(comment);
                        var newBlogPostCatched = list.blogPosts.Where(b => b.id == id).FirstOrDefault();
                        newBlogPostCatched.comments = newList;
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }



                var convertedJson = JsonConvert.SerializeObject(list, Formatting.Indented);

                using (var writer = new StreamWriter(filePath))
                {
                    writer.Write(convertedJson);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(View());
        }
Пример #4
0
        public JsonResult LayEditUploadFile()
        {
            Rootobject info = new Rootobject();

            info.data = new Data();
            try
            {
                var file       = Request.Files[0]; //获取选中文件
                var filecombin = file.FileName.Split('.');
                if (file == null || string.IsNullOrEmpty(file.FileName) || file.ContentLength == 0 || filecombin.Length < 2)
                {
                    info.code       = -1;
                    info.msg        = "上传出错!请检查文件名或文件内容";
                    info.data.src   = "";
                    info.data.title = "";
                    return(Json(info));
                }
                //定义本地路径位置
                string UpImgPath    = string.Format("/Upload/LayEdit/{0}", DateTime.Now.ToShortDateString());
                string localPath    = Server.MapPath(UpImgPath);
                string filePathName = string.Empty;

                string tmpName  = Server.MapPath(UpImgPath);
                var    tmp      = file.FileName;
                var    tmpIndex = 0;
                //判断是否存在相同文件名的文件 相同累加1继续判断
                while (System.IO.File.Exists(tmpName + tmp))
                {
                    tmp = filecombin[0] + "_" + ++tmpIndex + "." + filecombin[1];
                }
                //不带路径的最终文件名
                filePathName = tmp;

                if (!System.IO.Directory.Exists(localPath))
                {
                    System.IO.Directory.CreateDirectory(localPath);
                }

                file.SaveAs(Path.Combine(tmpName, filePathName));   //保存图片(文件夹)

                info.code       = 0;
                info.msg        = "上传成功";
                info.data.src   = Path.Combine(UpImgPath, filePathName);
                info.data.title = "";

                #region 编辑器返回json格式
                //{
                //      "code": 0 //0表示成功,其它失败
                //      ,"msg": "" //提示信息 //一般上传失败后返回
                //      ,"data":
                //      {
                //          "src": "图片路径"
                //          ,"title": "图片名称" //可选
                //      }
                //}
                #endregion

                return(Json(info));
            }
            catch (Exception ex)
            {
                info.code = -1;
                info.msg  = ex.Message;
                return(Json(info, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public void ParseYmlIcons()
        {
            var Iconyml = @"
icons:
  - name:       Glass
    id:         glass
    unicode:    f000
    created:    1.0
    filter:
      - martini
      - drink
      - bar
      - alcohol
      - liquor
    categories:
      - Web Application Icons

  - name:       Music
    id:         music
    unicode:    f001
    created:    1.0
    filter:
      - note
      - sound
    categories:
      - Web Application Icons

  - name:       Search
    id:         search
    unicode:    f002
    created:    1.0
    filter:
      - magnify
      - zoom
      - enlarge
      - bigger
    categories:
      - Web Application Icons
";

            // Setup the input
            var input = new StringReader(Iconyml);
            //var input = new StringReader(Iconyml);
            //String yamlText = File.ReadAllText(Iconyml);
            // Load the stream
            //var yaml = new YamlStream();
            //yaml.Load(input);
            Deserializer deserializer = new Deserializer();
            //Rootobject root = deserializer.Deserialize<Rootobject>(new StringReader(Iconyml));
            Rootobject root = deserializer.Deserialize <Rootobject>(input);

            //ReDocument root = deserializer.Deserialize<ReDocument>(input);
            if (root == null)
            {
                Console.WriteLine("Root is null");
            }
            else
            {
                Console.WriteLine("Root is not null: " + root.icons.Count);
            }
        }
Пример #6
0
 public Boolean cmp(Rootobject json1, Rootobject json2)
 {
     return(json1.cmp(json2));
 }
Пример #7
0
        static async Task <int> Main()
        {
            var baseUrl = "http://172.31.211.17:9000/";

            _uri = new Uri(baseUrl);

            var scheme        = "Basic";
            var userName      = "******";
            var password      = "******";
            var parameter     = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{userName}:{password}"));
            var authValue     = new AuthenticationHeaderValue(scheme, parameter);
            var pageSize      = 500;
            int pageIndex     = 1;
            var urlPathFormat = "api/issues/search?componentKeys=LISA.Core.6.0.master&s=FILE_LINE&languages=cs&resolved=false&rules=csharpsquid%3AS3776&severities=CRITICAL&ps={0}&organization=default-organization&p={1}&additionalFields=_all";

            try
            {
                List <Issue> issues = new List <Issue>();
                bool         flag   = true;
                while (flag)
                {
                    var urlPath = string.Format(urlPathFormat, pageSize, pageIndex);
                    var content = await GetReport(authValue, urlPath);

                    Rootobject json = JsonConvert.DeserializeObject <Rootobject>(content);
                    if (json == null)
                    {
                        throw new Exception($"Can not parse {content} to json");
                    }
                    issues.AddRange(json.issues);
                    var paging = json.paging;

                    if (paging.pageIndex * pageSize >= paging.total)
                    {
                        flag = false;
                    }
                    else
                    {
                        pageIndex++;
                    }
                }

                DataTable table = DataTableHelper.CreateDataTable();
                Dictionary <string, int> dic = new Dictionary <string, int>();
                foreach (var issue in issues)
                {
                    var component = issue.component;
                    if (!dic.ContainsKey(component))
                    {
                        dic.Add(component, 1);
                    }
                    else
                    {
                        var count = dic[component] + 1;
                        dic[component] = count;
                    }

                    var row   = table.NewRow();
                    var index = table.Rows.Count;
                    row[DataTableHelper.columnId]        = index + 1;
                    row[DataTableHelper.columnComponent] = component;
                    var message = issue.message;
                    row[DataTableHelper.columnComplexity] = GetCyclomaticComplexity(message);
                    table.Rows.Add(row);
                }

                foreach (DataRow row in table.Rows)
                {
                    var key = row[DataTableHelper.columnComponent].ToString();
                    row[DataTableHelper.columnComponentCount] = dic[key];
                }


                var fileName = $"SonarqubeReport-{DateTime.Now:yyyyMMddHHmmssfff}.xlsx";
                var folder   = PathHelper.GetDownloadFolderPath();
                var filePath = Path.Combine(folder, fileName);
                ExcelHelper.DataTableToExcel(table, filePath);
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine(ex);
            }

            return(0);
        }
Пример #8
0
        public void SetData(string jsonData)
        {
            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Rootobject));
            MemoryStream ms         = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(jsonData));
            Rootobject   rootObject = (Rootobject)js.ReadObject(ms);

            DataTable dt = new DataTable();

            try
            {
                StringBuilder csv = new StringBuilder();
                foreach (string columnName in rootObject.returnValue.columnNames)
                {
                    if (columnName.Contains("_SMI_"))
                    {
                        dt.Columns.Add(columnName, typeof(Image));
                    }
                    else
                    {
                        dt.Columns.Add(columnName);
                    }

                    if (csv.Length > 0)
                    {
                        csv.Append(",");
                    }
                    csv.Append(columnName);
                }
                csv.Append("\n");

                int rowsadded          = 0;
                int totalRows          = rootObject.returnValue.rows.Length;
                CdkMx.CdkMolControl hr = new CdkMx.CdkMolControl();
                hr.Preferences.BackColor = Color.Transparent;

                int MaxDisplayRows = 100;

                StringBuilder rowSb = new StringBuilder();

                foreach (Row row in rootObject.returnValue.rows)
                {
                    rowSb.Clear();

                    DataRow dr = dt.NewRow();
                    for (int index = 0; index < row.data.Length; index++)
                    {
                        string colName = rootObject.returnValue.columnNames[index];
                        if (colName == null)
                        {
                            colName = "";
                        }

                        if (index > 0)
                        {
                            rowSb.Append(",");
                        }

                        object vo = row.data[index];

                        if (vo == null || vo is DBNull)
                        {
                            dr[index] = "";
                            continue;
                        }

                        rowSb.Append(vo.ToString());

                        if (colName.Contains("_SMI_"))
                        {
                            string smiles = (string)vo;
                            if (!string.IsNullOrEmpty(smiles) && dt.Rows.Count < MaxDisplayRows)                              // avoid running out of memory with  bitmaps
                            {
                                //double sbl = hr.Preferences.StandardBondLength;
                                try
                                {
                                    Bitmap bm = hr.PaintMolecule(MoleculeFormat.Smiles, smiles, 200, 200);
                                    dr[index] = bm;
                                }
                                catch (Exception ex)
                                {
                                    ComOps.DebugLog.Message(ex.Message);
                                    Bitmap bitmap = new Bitmap(200, 200);
                                    dr[index] = bitmap;
                                }
                                continue;
                            }
                            dr[index] = "";
                        }

                        else
                        {
                            dr[index] = vo;
                        }
                    }
                    dt.Rows.Add(dr);
                    csv.Append(rowSb + "n");

                    rowsadded++;
                    Progress.Show("Loading Matched Pairs Viewer Row: " + rowsadded + " of " + totalRows, "Row Retrieval", false);
                }

                if (true)
                {
                    try                       // also write csv file
                    {
                        StreamWriter sw = new StreamWriter(@"c:\download\MMPDynamicWebServiceData.csv");
                        sw.Write(csv.ToString());
                        sw.Close();
                    }
                    catch (Exception ex) { }
                }

                gridView1.RowHeight = 200;

                foreach (string columnName in rootObject.returnValue.columnNames)
                {
                    if (columnName.Contains("_SMI_"))
                    {
                        gridView1.Columns[columnName].ColumnEdit = new RepositoryItemPictureEdit();
                        gridView1.Columns[columnName].Width      = 200;
                    }
                }

                gridControl1.DataSource = dt;
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }

            //foreach (string columnName in rootObject.returnValue.columnNames)
            //{
            //    if (columnName.Contains("_SMI_"))
            //    {
            //        gridView1.Columns[columnName].ColumnEdit = new RepositoryItemPictureEdit();
            //    }

            //}


            //for (int index = 0; index < rootObject.returnValue.columnNames.Length; index++)
            //{
            //    //if (rootObject.returnValue.columnDataTypes[index] == "String")
            //    //{
            //        GridColumn gridColumn = new GridColumn();
            //        gridColumn.Name = rootObject.returnValue.columnNames[index];
            //        gridView1.Columns.Add(gridColumn);


            //    //}

            //}

            //for (int index = 0; index < rootObject.returnValue.rows.Length; index++)
            //{
            //    //if (rootObject.returnValue.columnDataTypes[index] == "String")
            //    //{
            //    gridView1.AddNewRow();

            //    //}

            //}

            //List<Row> myRows = rootObject.returnValue.rows.ToList();
            //gridView1.DataSource = myRows;
        }
Пример #9
0
        public ActionResult Index()
        {
            Rootobject viewModel = new Rootobject();

            return(View());
        }
Пример #10
0
 public void Init(Rootobject obj)
 {
     TroopsDictById          = obj.Troops.ToDictionary(t => t.Id);
     TroopsDictByRarity      = obj.Troops.GroupBy(t => t.TroopRarity).ToDictionary(t => t.Key, l => l.ToList());
     TroopsCountDictByRarity = obj.Troops.GroupBy(t => t.TroopRarity).ToDictionary(t => t.Key, c => c.Count());
 }
Пример #11
0
        static string API_KEY  = "iiHnOKfno2Mgkt5AynpvPpUQTEyxE77jo1RU8PIv"; //Add your API key here inside ""

        // Obtaining the API key is easy. The same key should be usable across the entire
        // data.gov developer network, i.e. all data sources on data.gov.
        public IActionResult mainpage()
        {
            httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Accept.Clear();
            httpClient.DefaultRequestHeaders.Add("X-Api-Key", API_KEY);
            httpClient.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            ////To populate our database we inserted four different offenses into the API string:
            ////aggravated-assault, burglary, larceny, and violent-crime.
            string NATIONAL_PARK_API_PATH = BASE_URL + "/api/summarized/state/TX/aggravated-assault/2009/2019";
            string parksData = "";

            Rootobject root = null;

            httpClient.BaseAddress = new Uri(NATIONAL_PARK_API_PATH);

            try
            {
                HttpResponseMessage response = httpClient.GetAsync(NATIONAL_PARK_API_PATH).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    parksData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                }

                if (!parksData.Equals(""))
                {
                    // JsonConvert is part of the NewtonSoft.Json Nuget package
                    root = JsonConvert.DeserializeObject <Rootobject>(parksData);
                }

                //if (!dbContext.Results.Where(_ => true).Any())
                //{
                foreach (Result x in root.results)
                {
                    dbContext.Results.Add(x);
                }
                dbContext.SaveChanges();
                //}
            }
            catch (Exception e)
            {
                // This is a useful place to insert a breakpoint and observe the error message
                Console.WriteLine(e.Message);
            }

            //Manually populate the ORI table, which will be used for a master-detail relationship with Result
            //ORI ori1 = new ORI();
            //ori1.nameORI = "TX0010000";
            //ori1.county = "Anderson";

            //ORI ori2 = new ORI();
            //ori2.nameORI = "TX0010100";
            //ori2.county = "Anderson";

            //ORI ori3 = new ORI();
            //ori3.nameORI = "TX0010300";
            //ori3.county = "Anderson";

            //ORI ori4 = new ORI();
            //ori4.nameORI = "TX0020000";
            //ori4.county = "Andrews";

            //ORI ori5 = new ORI();
            //ori5.nameORI = "TX0020100";
            //ori5.county = "Andrews";

            //ORI ori6 = new ORI();
            //ori6.nameORI = "TX0030000";
            //ori6.county = "Angelina";

            //ORI ori7 = new ORI();
            //ori7.nameORI = "TX0030100";
            //ori7.county = "Angelina";

            //ORI ori8 = new ORI();
            //ori8.nameORI = "TX0030200";
            //ori8.county = "Angelina";

            //ORI ori9 = new ORI();
            //ori9.nameORI = "TX0030400";
            //ori9.county = "Angelina";

            //ORI ori10 = new ORI();
            //ori10.nameORI = "TX0031300";
            //ori10.county = "Angelina";

            //ORI ori11 = new ORI();
            //ori11.nameORI = "TX0040000";
            //ori11.county = "Aransas";

            //ORI ori12 = new ORI();
            //ori12.nameORI = "TX0040100";
            //ori12.county = "Aransas";

            //ORI ori13 = new ORI();
            //ori13.nameORI = "TX0040200";
            //ori13.county = "Aransas";

            //ORI ori14 = new ORI();
            //ori14.nameORI = "TX0050000";
            //ori14.county = "Archer";

            //ORI ori15 = new ORI();
            //ori15.nameORI = "TX0050200";
            //ori15.county = "Archer";

            //ORI ori16 = new ORI();
            //ori16.nameORI = "TX0060000";
            //ori16.county = "Armstrong";

            //ORI ori17 = new ORI();
            //ori17.nameORI = "TX0070000";
            //ori17.county = "Atascosa";

            //ORI ori18 = new ORI();
            //ori18.nameORI = "TX0070100";
            //ori18.county = "Atascosa";

            //ORI ori19 = new ORI();
            //ori19.nameORI = "TX0070200";
            //ori19.county = "Atascosa";

            //ORI ori20 = new ORI();
            //ori20.nameORI = "TX0070300";
            //ori20.county = "Atascosa";

            //dbContext.Agencies.Add(ori1);
            //dbContext.Agencies.Add(ori2);
            //dbContext.Agencies.Add(ori3);
            //dbContext.Agencies.Add(ori4);
            //dbContext.Agencies.Add(ori5);
            //dbContext.Agencies.Add(ori6);
            //dbContext.Agencies.Add(ori7);
            //dbContext.Agencies.Add(ori8);
            //dbContext.Agencies.Add(ori9);
            //dbContext.Agencies.Add(ori10);
            //dbContext.Agencies.Add(ori11);
            //dbContext.Agencies.Add(ori12);
            //dbContext.Agencies.Add(ori13);
            //dbContext.Agencies.Add(ori14);
            //dbContext.Agencies.Add(ori15);
            //dbContext.Agencies.Add(ori16);
            //dbContext.Agencies.Add(ori17);
            //dbContext.Agencies.Add(ori18);
            //dbContext.Agencies.Add(ori19);
            //dbContext.Agencies.Add(ori20);

            //dbContext.SaveChanges();


            return(View(root)); //root
        }
Пример #12
0
        public ActionResult AddNotebook(Rootobject jsonObject)
        {
            if (jsonObject != null)
            {
                var notebookDate = jsonObject.notebookDate;
                var numberOfDays = jsonObject.numberOfDays;
                var notebookData = jsonObject.notebookData;

                var ratio       = 1.0;
                var persianDate = PersianDateTime.Parse(notebookDate);
                var englishTime = persianDate.ToDateTime();


                switch (Convert.ToInt32(numberOfDays))
                {
                case 1:
                    ratio = 6;
                    break;

                case 2:
                    ratio = 3;
                    break;

                case 3:
                    ratio = 2;
                    break;

                case 4:
                    ratio = 1.5;
                    break;

                case 5:
                    ratio = 1.2;
                    break;

                default:
                    ratio = 1;
                    break;
                }

                var notebooks = new List <Notebook>();

                for (int i = 0; i < notebookData.Length; i++)
                {
                    var stuID = Convert.ToInt32(notebookData[i].StudentId);
                    var grade = Convert.ToInt32(notebookData[i].Grade) * (float)ratio;
                    //پرکردن ارایه از تمرین ها
                    notebooks.Add(new Notebook
                    {
                        StudentID    = stuID,
                        Grade        = grade,
                        NoteBookDate = englishTime
                    });
                }

                _context.Notebooks.AddRange(notebooks);
                _context.SaveChanges();



                return(Content("اطلاعات وارد شد"));
            }
            else
            {
                return(Content("An Error Has occoured"));
            }
        }
Пример #13
0
        /// <summary>
        /// Loads rules from the main rules file and override file
        /// </summary>
        /// <returns>A RootNodes object containing all the rules after being merged</returns>
        public RootNodes Load()
        {
            var mainNamespaceFileTasks = new Task <NamespaceRecommendations>(() =>
            {
                NamespaceRecommendations rulesFile = new NamespaceRecommendations();
                if (!string.IsNullOrEmpty(_rulesFilesDir) && Directory.Exists(_rulesFilesDir))
                {
                    rulesFile = LoadNamespaceFile(_rulesFilesDir);
                }
                return(rulesFile);
            });

            mainNamespaceFileTasks.Start();

            var mainFileTask = new Task <Rootobject>(() =>
            {
                Rootobject rules = new Rootobject();
                if (!string.IsNullOrEmpty(_rulesFilesDir) && Directory.Exists(_rulesFilesDir))
                {
                    rules = LoadRulesFiles(_rulesFilesDir);
                    if (rules.NameSpaces != null)
                    {
                        rules.NameSpaces = rules.NameSpaces.Where(n => _projectReferences.Contains(new Reference()
                        {
                            Assembly = n.Assembly, Namespace = n.@namespace
                        }) || (n.Assembly == Constants.Project)).ToList();
                    }
                }
                return(rules);
            });

            mainFileTask.Start();

            var overrideNamespaceFileTasks = new Task <NamespaceRecommendations>(() =>
            {
                NamespaceRecommendations rulesFile = new NamespaceRecommendations();
                if (!string.IsNullOrEmpty(_overrideFile) && Directory.Exists(_overrideFile))
                {
                    rulesFile = LoadNamespaceFile(_overrideFile);
                }
                return(rulesFile);
            });

            overrideNamespaceFileTasks.Start();

            var overrideTask = new Task <Rootobject>(() =>
            {
                Rootobject rules = new Rootobject();
                if (!string.IsNullOrEmpty(_overrideFile) && Directory.Exists(_overrideFile))
                {
                    rules = LoadRulesFiles(_overrideFile);
                    if (rules.NameSpaces != null)
                    {
                        rules.NameSpaces = rules.NameSpaces.Where(n => _projectReferences.Contains(new Reference()
                        {
                            Assembly = n.Assembly, Namespace = n.@namespace
                        }) || (n.Assembly == Constants.Project && n.@namespace == Constants.Project)).ToList();
                    }
                }
                return(rules);
            });

            overrideTask.Start();

            Task.WaitAll(mainNamespaceFileTasks, overrideNamespaceFileTasks, mainFileTask, overrideTask);

            RulesFileParser rulesFileParser = new RulesFileParser(mainNamespaceFileTasks.Result,
                                                                  overrideNamespaceFileTasks.Result,
                                                                  mainFileTask.Result,
                                                                  overrideTask.Result,
                                                                  _assembliesDir,
                                                                  _targetFramework
                                                                  );
            var rootNodes = rulesFileParser.Process();

            return(rootNodes);
        }
Пример #14
0
        public void Create(string firstName, string middleName, string lastName, string DOB, string email,
                           string phone, string gender, string occupation, string address, string city, string state, string country,
                           string password, string confirmPassword, string username)
        {
            GithubInfo githubInfo = new GithubInfo();

            githubInfo.httpMethod = httpVerb.POST;

            Email emaill = new Email();

            emaill.Email1 = email;

            Phone phoneTemp = new Phone();

            phoneTemp.Phone1 = phone;

            Occupation occupationTemp = new Occupation();

            occupationTemp.JobTitle = occupation;

            Address addressTemp = new Address();

            addressTemp.Address1 = address;
            addressTemp.City     = city;
            addressTemp.State    = state;
            addressTemp.Country  = country;


            if (password != confirmPassword)
            {
            }

            Rootobject rootobject = new Rootobject();

            rootobject.FirstName   = firstName;
            rootobject.MiddleName  = middleName;
            rootobject.LastName    = lastName;
            rootobject.Username    = username;
            rootobject.Password    = password;
            rootobject.CreatedDate = DateTime.Now;
            //rootobject.DOB = DOB.ToString();


            rootobject.Emails.Add(emaill);


            rootobject.Phones.Add(phoneTemp);

            ////rootobject.Gender = gender;


            rootobject.Occupations.Add(occupationTemp);


            rootobject.Addresses.Add(addressTemp);



            githubInfo.endPoint = "http://api.power-supreme.com/api/Default/PostUser";

            int returnValue = githubInfo.PostRequest(rootobject);
        }
Пример #15
0
 // Start is called before the first frame update
 void Start()
 {
     loadedData = new Rootobject();
     LoadJSON();
 }
Пример #16
0
        public JsonResult getTreeViewData()
        {
            Rootobject treeData = null;

            if (Session["myExcelData"] != null)
            {
                List <Category> categories  = null;
                bool            isSavedToDB = Session["saveToDB"] != null && (bool)Session["saveToDB"];
                if (isSavedToDB)
                {
                    categories = Repository.GetAllCategories();
                }
                else
                {
                    categories = (List <Category>)Session["myExcelData"];
                }

                List <Category> swCategories = categories.Where(c => c.Type == "SW").ToList();
                List <Category> hwCategories = categories.Where(c => c.Type == "HW").ToList();

                treeData = new Rootobject()
                {
                    Property1 = new List <Class1>()
                    {
                        new Class1()
                        {
                            text     = "HardWarwe",
                            expanded = true,
                            items    = new List <Item>()
                            {
                                new Item()
                                {
                                    id = hwCategories[0].Id, text = hwCategories[0].Name
                                },
                                new Item()
                                {
                                    id = hwCategories[1].Id, text = hwCategories[1].Name
                                }
                            }
                        },
                        new Class1()
                        {
                            text     = "Software",
                            expanded = true,
                            items    = new List <Item>()
                            {
                                new Item()
                                {
                                    id = swCategories[0].Id, text = swCategories[0].Name
                                },
                                new Item()
                                {
                                    id = swCategories[1].Id, text = swCategories[1].Name
                                }
                            }
                        }
                    }
                };
            }
            else
            {
                treeData = new Rootobject()
                {
                    Property1 = new List <Class1>()
                    {
                        new Class1()
                        {
                            text = "HardWarwe"
                        },
                        new Class1()
                        {
                            text = "Software"
                        }
                    }
                };
            }



            return(this.Json(treeData.Property1, JsonRequestBehavior.AllowGet));
        }
Пример #17
0
        /// <summary>
        /// Metodo asincrono che effettua la ricerca nel database.
        /// </summary>
        /// <param name="sender">Oggetto source dell'evento.</param>
        /// <param name="e">L'istanza <see cref="EventArgs"/> che contiene i dati dell'evento.</param>
        private async void Search_btn_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in Film_Table.Rows)
            {
                Film_Table.Rows.Clear();
            }
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://www.omdbapi.com/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                string Ricerca, query, url;
                if (string.IsNullOrEmpty(search_textbox.Text))
                {
                    MessageBox.Show("Compila il campo di ricerca", "Errore");
                }
                else
                {
                    Ricerca = search_textbox.Text;

                    if (filtro_anno && AnnoBox.SelectedIndex == -1)
                    {
                        MessageBox.Show("Compila i campi del filtro", "Errore");
                        query = "errore";
                    }
                    else
                    {
                        query = "?s=" + Ricerca + "&apikey=" + Program.ApiKey;
                        if (filtro_tipologia)
                        {
                            query += "&type=" + (filmradio.Checked ? "movie" : "series");
                        }
                        if (filtro_anno)
                        {
                            query += "&y=" + AnnoBox.SelectedItem.ToString();
                        }
                    }

                    AnnoBox.SelectedIndex = -1;

                    HttpResponseMessage response = await client.GetAsync(query);

                    if (response.IsSuccessStatusCode)
                    {
                        using (WebClient web = new WebClient())
                        {
                            csv = "";
                            url = "http://www.omdbapi.com/" + query;
                            var json   = web.DownloadString(url);
                            var result = JsonConvert.DeserializeObject <Rootobject>(json);
                            output = result;
                            if (output.Response == "False")
                            {
                                MessageBox.Show("Nessun film trovato", "Errore");
                            }
                            else
                            {
                                int length = output.Search.Length;
                                int num    = 1;
                                for (int i = 0; i < length; i++)
                                {
                                    output.Search[i].Year = output.Search[i].Year.Replace("–", "-");
                                    Film_Table.Rows.Add(num.ToString(), output.Search[i].Title, output.Search[i].Year, output.Search[i].Type);
                                    csv += num.ToString() + ";" + output.Search[i].Title + ";" + output.Search[i].Year + ";" + output.Search[i].Type + "\n";
                                    num++;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
 public async void LoadProjects()
 {
     this.Projects = await _apiServices.GetProjects();
 }
Пример #19
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            View activeView = doc.ActiveView;

            List <Autodesk.Revit.DB.SpatialElement> rooms = new FilteredElementCollector(doc, activeView.Id).OfClass(typeof(Autodesk.Revit.DB.SpatialElement)).Cast <Autodesk.Revit.DB.SpatialElement>().ToList();

            List <float[][]> FnlPoints = new List <float[][]>();
            List <string>    roomNames = new List <string>();

            foreach (Autodesk.Revit.DB.Architecture.Room R in rooms)
            {
                IList <IList <Autodesk.Revit.DB.BoundarySegment> > segments = R.GetBoundarySegments(new SpatialElementBoundaryOptions());
                if (null != segments)  //the room may not be bound
                {
                    roomNames.Add(R.Name);
                    foreach (IList <Autodesk.Revit.DB.BoundarySegment> segmentList in segments)
                    {
                        //List to storage all points

                        List <XYZ>    roomPoints = new List <XYZ>();
                        List <string> testtt     = new List <string>();
                        foreach (Autodesk.Revit.DB.BoundarySegment boundarySegment in segmentList)
                        {
                            // Get curve start point
                            XYZ start = boundarySegment.GetCurve().GetEndPoint(0);
                            roomPoints.Add(start);
                            // Get curve end point
                            XYZ end = boundarySegment.GetCurve().GetEndPoint(1);
                            roomPoints.Add(end);
                        }

                        FnlPoints.Add(LocationPoints(roomPoints));
                    }
                }
            }


            Rootobject RacksList = new Rootobject();

            List <Feature> featuresArray = new List <Feature> {
            };

            //Define info of each room
            for (int i = 0; i < roomNames.Count; i++)
            {
                //Define property
                Properties tempProperty = new Properties();

                //Define Coordinates
                float[][][] tempCoordinates = new float[1][][];
                float[][]   tempFloat       = new float[FnlPoints[i].Length][];
                tempFloat = FnlPoints[i];

                tempCoordinates[0] = tempFloat;

                //Define geometry
                Geometry temGeom = new Geometry();
                temGeom.type        = "Polygon";
                temGeom.coordinates = tempCoordinates;


                //Define temGeom as current feature geomtry
                Feature tempFeature = new Feature();
                tempFeature.type       = "Feature";
                tempFeature.properties = tempProperty;
                tempFeature.geometry   = temGeom;

                //Add feature to array
                featuresArray.Add(tempFeature);
            }

            Feature[] currentFeatures = new Feature[roomNames.Count];
            currentFeatures = featuresArray.ToArray();


            RacksList = new Rootobject
            {
                type     = "FeatureCollection",
                features = currentFeatures,
            };

            string path = @"C:\Users\V. Noves\Downloads\Test.json";

            export.serializeJason(RacksList, path);
        }
Пример #20
0
    /// <summary>
    /// 海报1
    /// </summary>
    /// <param name="openid"></param>
    /// <returns></returns>
    public OAauth_Log SeadSeaNews(OAauth_Log oa)
    {
        string img = "/assets/img/bottom.jpg";

        img = Server.MapPath(img);
        string headimg = "/wechat/spa/image/logo.jpg";
        string qrimg   = "/wechat/spa/image/logo.jpg";

        if (oa != null)
        {
            if (string.IsNullOrEmpty(oa.Ticket))                                                                                                      //如果没有生成过邀请二维码,则生成一个。
            {
                string   jason      = "{\"action_name\": \"QR_LIMIT_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + (oa.ID + 10000) + "}}}"; //oa的id增加一万
                string   resMessage = WeiPage.HttpXmlPostRequest("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + Token(mjuserid), jason, Encoding.UTF8);
                string[] a          = resMessage.Split('\"');
                if (a.Length > 3)
                {
                    oa.Ticket = Server.UrlEncode(a[3]);
                    DownQRImage(oa.Ticket);
                    qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg";
                }
            }
            else
            {
                qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg";
            }
            qrimg = Server.MapPath(qrimg);
            if (!string.IsNullOrEmpty(oa.DownPic))
            {
                headimg = oa.DownPic;
            }
            else if (!string.IsNullOrEmpty(oa.headimgurl))
            {
                string down = DownHeadImage(oa);
                if (!string.IsNullOrEmpty(down))
                {
                    headimg = down;
                }
            }
            headimg = Server.MapPath(headimg);

            string img2 = @"E:\ASPNETTempFiles\seanews\";
            if (!System.IO.Directory.Exists(img2))
            {
                Directory.CreateDirectory(img2);
            }
            oa.SeaImg = Guid.NewGuid().ToString();
            img2     += oa.SeaImg + ".jpg";
            if (File.Exists(img) && File.Exists(headimg) && File.Exists(qrimg))
            {
                ImageWriter           iw       = new ImageWriter();
                System.Drawing.Bitmap bm       = new System.Drawing.Bitmap(headimg);
                System.Drawing.Image  newImage = CutEllipse(bm, new Rectangle(0, 0, bm.Width, bm.Height), new Size(200, 200));
                iw.SaveWatermark(new System.Drawing.Bitmap(img), (Bitmap)newImage, ImageWriter.WatermarkPosition.LeftTop, 90, 70, new System.Drawing.Bitmap(qrimg), ImageWriter.WatermarkPosition.LeftBottom, 220, 50, img2, oa.Nickname);; // f.FILE_NAME, Server.MapPath("~/assets/images/shuiyin.png"), Server.MapPath("~/assets/images/shuiyin2.png"), Server.MapPath("~/assets/images/shuiyin3.png"), 0.3f, ImageWriter.WatermarkPosition.Center, 10, f.FILE_NAME);
            }

            if (File.Exists(img2))
            {
                List <string> imglist = new List <string>();
                imglist.Add(img2);
                string a        = HttpUploadFile("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + Token(mjuserid) + "&type=image", "图片", "application/x-jpg", new System.Collections.Specialized.NameValueCollection {
                }, imglist);
                Rootobject root = JsonConvert.DeserializeObject <Rootobject>(a);
                if (root.media_id != null)
                {
                    oa.MEDIA_ID   = root.media_id;
                    oa.MEDIA_Time = DateTime.Now.AddDays(3).AddHours(-2);
                    mss.SaveOA(oa);
                    return(oa);
                }
            }
        }
        return(oa);
    }
Пример #21
0
 public String SerializeJson(Rootobject json)
 {
     return(JsonConvert.SerializeObject(json, Formatting.Indented));
 }
Пример #22
0
    /// <summary>
    /// 佰草集邀请海报1
    /// </summary>
    /// <param name="openid"></param>
    /// <returns></returns>
    public string SeadSeaNews_BCJ(string openid, int SeaSource)
    {
        string img = "/assets/img/poster.jpg";

        img = Server.MapPath(img);
        string     headimg = "/wechat/spa/image/logo.jpg";
        string     qrimg   = "/wechat/spa/image/logo.jpg";
        OAauth_Log oa      = mss.GetOA(openid);

        if (oa != null)
        {
            if (!oa.SeaSource.HasValue)
            {
                oa.SeaSource = SeaSource;
            }

            if (!string.IsNullOrEmpty(oa.MEDIA_ID) && oa.MEDIA_Time.HasValue && oa.MEDIA_Time > DateTime.Now)
            {
                return(oa.MEDIA_ID);             //如果已有海报,并且未过期,则直接返回之前的海报。
            }
            if (string.IsNullOrEmpty(oa.Ticket)) //如果没有生成过邀请二维码,则生成一个。
            {
                //string access_token = w.Token(w.mjuserid);
                string   jason      = "{\"action_name\": \"QR_LIMIT_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + (oa.ID + 10000) + "}}}"; //oa的id增加一万
                string   resMessage = WeiPage.HttpXmlPostRequest("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + Token(mjuserid), jason, Encoding.UTF8);
                string[] a          = resMessage.Split('\"');
                if (a.Length > 3)
                {
                    oa.Ticket = Server.UrlEncode(a[3]);
                    DownQRImage(oa.Ticket);
                    qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg";
                }
            }
            else
            {
                qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg";
            }
            qrimg = Server.MapPath(qrimg);
            if (!string.IsNullOrEmpty(oa.DownPic))
            {
                headimg = oa.DownPic;
            }
            else if (!string.IsNullOrEmpty(oa.headimgurl))
            {
                string down = DownHeadImage(oa);
                if (!string.IsNullOrEmpty(down))
                {
                    headimg = down;
                }
            }
            headimg = Server.MapPath(headimg);

            string img2 = @"D:\ASPNETTempFiles\seanews\";
            if (!System.IO.Directory.Exists(img2))
            {
                Directory.CreateDirectory(img2);
            }
            oa.SeaImg = Guid.NewGuid().ToString();
            img2     += oa.SeaImg + ".jpg";
            if (File.Exists(img) && File.Exists(headimg) && File.Exists(qrimg))
            {
                ImageWriter           iw       = new ImageWriter();
                System.Drawing.Bitmap bm       = new System.Drawing.Bitmap(headimg);
                System.Drawing.Image  newImage = CutEllipse(bm, new Rectangle(0, 0, bm.Width, bm.Height), new Size(200, 200));
                using (Image image = Image.FromFile(img))
                {
                    if (IsPixelFormatIndexed(image.PixelFormat))
                    {
                        Bitmap bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb);
                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                            g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                            g.DrawImage(image, 0, 0);
                        }

                        iw.SaveWatermark(bmp, (Bitmap)newImage, ImageWriter.WatermarkPosition.LeftTop, 120, 120, new System.Drawing.Bitmap(qrimg), ImageWriter.WatermarkPosition.LeftBottom, 130, 30, img2, oa.Nickname);; // f.FILE_NAME, Server.MapPath("~/assets/images/shuiyin.png"), Server.MapPath("~/assets/images/shuiyin2.png"), Server.MapPath("~/assets/images/shuiyin3.png"), 0.3f, ImageWriter.WatermarkPosition.Center, 10, f.FILE_NAME);
                    }
                    else
                    {
                        iw.SaveWatermark(new System.Drawing.Bitmap(img), (Bitmap)newImage, ImageWriter.WatermarkPosition.LeftTop, 120, 120, new System.Drawing.Bitmap(qrimg), ImageWriter.WatermarkPosition.LeftBottom, 130, 30, img2, oa.Nickname);
                    };                                                                                                                                                                                                                                // f.FILE_NAME, Server.MapPath("~/assets/images/shuiyin.png"), Server.MapPath("~/assets/images/shuiyin2.png"), Server.MapPath("~/assets/images/shuiyin3.png"), 0.3f, ImageWriter.WatermarkPosition.Center, 10, f.FILE_NAME);
                }
            }

            if (File.Exists(img2))
            {
                List <string> imglist = new List <string>();
                imglist.Add(img2);
                string a        = HttpUploadFile("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + Token(mjuserid) + "&type=image", "图片", "application/x-jpg", new System.Collections.Specialized.NameValueCollection {
                }, imglist);
                Rootobject root = JsonConvert.DeserializeObject <Rootobject>(a);
                if (root.media_id != null)
                {
                    oa.MEDIA_ID   = root.media_id;
                    oa.MEDIA_Time = DateTime.Now.AddDays(3).AddHours(-2);
                    mss.SaveOA(oa);
                    return(root.media_id);
                    //        string message = @"{
                    //    ""touser"":""{0}"",
                    //    ""msgtype"":""image"",
                    //    ""image"":
                    //    {
                    //      ""media_id"":""{1}""
                    //    }
                    //}";
                    //        message = message.Replace("{0}", oa.FromUserName).Replace("{1}", root.media_id);
                    //        string Access_token = Token(mjuserid);

                    //        var postUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + Access_token;
                    //        string d = message;
                    //        //d = d.Replace("{0}", "oS7pm1iNL2P2pjdgHO3xC2NRdWE8").Replace("{1}", Message);
                    //        string resMessage = HttpXmlPostRequest(postUrl, d, Encoding.UTF8);
                }
            }
        }
        return("err");
    }
Пример #23
0
        /// <summary>
        /// translate a composite object as used by the 2009 ikcomponeer
        /// version (listen to the EmitEventAsTableEntity function to
        /// capture the data in the form of Events)
        /// </summary>
        /// <param name="root"></param>
        public void Translate(Rootobject root)
        {
            _projectEvents.AddRange(root.environment.projectRules.Where(
                                        x => x.type == "screenWidthInMeasures").Select(
                                        x => new ZoomFactorChange
            {
                Denominator = (int)x.value
            }
                                        ));

            _projectEvents.AddRange(root.environment.projectRules.Where(
                                        x => x.type == "trackHeight").Select(
                                        x =>
                                        new TrackHeightChange
            {
                Value = x.value
            }
                                        ));

            _environmentEvents.AddRange(root.environment.projectRules.Where(
                                            x => x.type == "bpmTempo").Select(
                                            x =>
                                            new TempoDefined
            {
                BpmTempo = x.value
            }
                                            ));

            _environmentEvents.Add(
                new MeasureDefined
            {
                Numerator   = (int)root.environment.projectRules.Single(x => x.type == "measureNumerator").value,
                Denominator = (int)root.environment.projectRules.Single(x => x.type == "beatDenominator").value
            });

            _projectEvents.Add(

                new QuantizeGridChange
            {
                Numerator   = (int)root.environment.projectRules.Single(x => x.type == "gridQuantizeNumerator").value,
                Denominator = (int)root.environment.projectRules.Single(x => x.type == "gridQuantizeDenominator").value
            });

            _environmentEvents.Add(
                new MusicSetCreated
            {
                id          = root.environment.projectMaterial.id,
                background  = root.environment.projectMaterial.background,
                description = root.environment.projectMaterial.textSlogan,
                name        = root.environment.projectMaterial.name,
                type        = root.environment.projectMaterial.type
            });

            var setId = root.environment.projectMaterial.id;

            var MusicPartCreatedSortList = new Dictionary <string, MusicPartCreated>();
            var MusicClipsSortLists      = new Dictionary <string, Dictionary <string, MusicClipCreated> >();

            var orderSuitableToSortOn =
                root.environment.projectMaterial.parts.Count == root.environment.projectMaterial.parts.GroupBy(x => x.Value.order).Count();

            foreach (var partKVP in root.environment.projectMaterial.parts)
            {
                var part   = partKVP.Value;
                var partId = part.id;

                var order = orderSuitableToSortOn ? part.order : part.id;

                MusicPartCreatedSortList.Add(order,
                                             new MusicPartCreated
                {
                    id      = part.id,
                    setId   = setId,
                    name    = part.name,
                    width   = part.width,
                    marginX = part.marginx,
                    marginY = part.marginy
                });

                MusicClipsSortLists.Add(order, new Dictionary <string, MusicClipCreated>());

                var clipsOrderSuitableToSortOn =
                    part.clips.Count == part.clips.GroupBy(x => x.Value.order).Count();

                foreach (var clipKVP in part.clips)
                {
                    var clip      = clipKVP.Value;
                    var clipOrder = clipsOrderSuitableToSortOn ? clip.order : clip.id;

                    MusicClipsSortLists[order].Add(clipOrder, new MusicClipCreated
                    {
                        id               = clip.id,
                        partId           = partId,
                        color            = clip.color,
                        entrypoint       = clip.entrypoint,
                        exitpoint        = clip.exitpoint,
                        ficon            = clip.ficon,
                        ficonroll        = clip.ficonroll,
                        iconAdjustHeight = clip.height,
                        icon             = clip.icon,
                        name             = clip.name,
                        tag              = clip.tag,
                        iconAdjustWidth  = clip.width
                    });
                }
            }

            var musicPartCreatedEvents = from x in MusicPartCreatedSortList
                                         orderby x.Key.Length, x.Key
            select x;



            foreach (var musicPartCreatedEvent in musicPartCreatedEvents)
            {
                _environmentEvents.Add(musicPartCreatedEvent.Value);

                var musicClipCreatedEvents = from y in MusicClipsSortLists[musicPartCreatedEvent.Key]
                                             orderby y.Key.Length, y.Key
                select y;

                foreach (var musicClipCreatedEvent in musicClipCreatedEvents)
                {
                    var clip = musicClipCreatedEvent.Value as MusicClipCreated;
                    var sort = musicClipCreatedEvent.Key;
                    _environmentEvents.Add(musicClipCreatedEvent.Value);
                }
            }

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_saveButtonVisible").Select(
                                        x => new SaveButtonVisibilityConfigured {
                Visible = x.Value == "1"
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonText")).Select(
                                        x => new ButtonTextConfigured
            {
                ButtonPosition = x.Key == "conf_topLeftButtonText" ? ButtonPosition.Left : ButtonPosition.Right,
                ButtonText     = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonTextSize")).Select(
                                        x => new ButtonTextSizeConfigured
            {
                ButtonPosition = x.Key == "topLeftButtonTextSize" ? ButtonPosition.Left : ButtonPosition.Right,
                Size           = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonNote")).Select(
                                        x => new ButtonBehaviorConfigured
            {
                ButtonPosition = x.Key == "conf_topLeftButtonNote" ? ButtonPosition.Left : ButtonPosition.Right,
                ButtonNote     = IkcNotificationTransformer.Transform(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonMode")).Select(
                                        x => new ButtonModeConfigured
            {
                ButtonPosition = x.Key == "conf_topLeftButtonMode" ? ButtonPosition.Left : ButtonPosition.Right,
                ButtonMode     = ButtonModeTransformer.Transform(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_showLoggerButtons").Select(
                                        x => new LoggerButtonsHidden()));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_licenseText").Select(
                                        x => new LicenseTextConfigured {
                Text = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_defaultTemplateCompositionId").Select(
                                        x => new TemplateCompositionConfigured {
                Id = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_slogan").Select(
                                        x => new SloganConfigured {
                Value = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_hide_subparts").Select(
                                        x => new SubpartsHidden {
                SubPartsCommaSeparated = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonClass")).Select(
                                        x => new ButtonClassConfigured
            {
                ButtonPosition = x.Key == "conf_topLeftButtonClass" ? ButtonPosition.Left : ButtonPosition.Right,
                ButtonClass    = ButtonClass.KarolaRondje
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_audiotips").Select(
                                        x => new AudioTipsConfigured
            {
                AudioTipsCommaSeperated = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_preview_playbuttonmode").Select(
                                        x => new PreviewPlayButtonModeConfigured
            {
                Value = x.Value == "upDown" ? PreviewPlayButtonMode.UpDown : PreviewPlayButtonMode.None
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_composition_playmode").Select(
                                        x => new CompositionPlayButtonModeConfigured
            {
                Value = x.Value == "upDown" ? CompositionPlayButtonMode.UpDown : CompositionPlayButtonMode.None
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_centerTracks").Select(
                                        x => new TracksCentered()));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_turnOffHelpBalloons").Select(
                                        x => new HelpBalloonsTurnedOff()));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_turnOffClipButtons").Select(
                                        x => new ClipButtonsTurnedOff()));

            _projectEvents.AddRange(root.conf_override.Where(
                                        x => x.Key == "conf_trackColorA").Select(x => new TrackColorDefined
            {
                Value = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(
                                        x => x.Key == "conf_trackColorB").Select(x => new TrackColorDefined
            {
                Value = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_tracksBackgroundImg").Select(
                                        x => new TracksBackgroundConfigured
            {
                BackgroundImage = x.Value
            }));

            _projectEvents.AddRange(root.environment.projectRules.Where(x => x.type == "trackHeight").Select(
                                        x => new TrackHeightConfigured
            {
                TrackHeight = (int)x.value
            }));


            _projectEvents.AddRange(root.environment.projectRules.Where(x => x.type == "numTracks").Select(
                                        x => new NumberOfTracksConfigured
            {
                NumberOfTracks = (int)x.value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_numTracks").Select(
                                        x => new NumberOfTracksConfigured
            {
                NumberOfTracks = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_trackHeight").Select(
                                        x => new TrackHeightConfigured
            {
                TrackHeight = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(
                                        x => x.Key.Contains("ButtonImg"))
                                    .Select(x => new ButtonImgConfigured
            {
                Img            = x.Value,
                ButtonPosition = x.Key.Contains("topRight") ? ButtonPosition.Right : ButtonPosition.Left
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_hideScroll").Select(
                                        x => new ScrollHiddenConfigured()));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_sloganFont").Select(
                                        x => new SloganFontConfigured
            {
                Font = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_sloganLineHeigt").Select(
                                        x => new SloganLineHeightConfigured
            {
                Height = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_sloganFontSize").Select(
                                        x => new SloganFontSizeConfigured
            {
                FontSize = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_sloganColor").Select(
                                        x => new SloganFontColorConfigured
            {
                Color = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_noTrackDrawing").Select(
                                        x => new TrackDrawingTypeConfigured
            {
                TrackDrawingType = x.Value == "true" ? TrackDrawingType.Hidden : TrackDrawingType.Default
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_magicDelay").Select(
                                        x => new MagicDelayConfigured
            {
                MagicDelay = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_playheadCircle").Select(
                                        x => new PlayHeadTypeConfigured
            {
                PlayHeadType = x.Value == "false" ? PlayHeadType.Hidden : PlayHeadType.Default
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_lineColor").Select(
                                        x => new PlayHeadLineColorConfigured
            {
                Color = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_subpartsTopMargin").Select(
                                        x => new TopMarginForSubpartsConfigured
            {
                TopMargin = int.Parse(x.Value)
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_noBorderClips").Select(
                                        x => new ClipDrawingTypeConfigured
            {
                ClipDrawingType = x.Value == "true" ? ClipDrawingType.NoBorders : ClipDrawingType.Default
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_noGrid").Select(
                                        x => new GridDrawingTypeConfigured
            {
                GridDrawingType = x.Value == "true" ? GridDrawingType.NoBorders : GridDrawingType.Default
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key.Contains("ButtonColor")).Select(
                                        x => new ButtonColorConfigured
            {
                ButtonPosition = x.Key.Contains("Right") ? ButtonPosition.Right : ButtonPosition.Left,
                Order          = int.Parse(x.Key.Last().ToString()),
                ButtonColor    = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_bgImg").Select(
                                        x => new BackgroundImageConfigured
            {
                BackgroundImage = x.Value
            }));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "maskButtonsOff").Select(
                                        x => new MaskButtonsTurnedOff
            {
                Off = true
            }));


            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_hideTrackBackground").Select(
                                        x => new TrackBackgroundHidden()));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_displayMenuRight").Select(
                                        x => new MenuDisplayHiddenRight()
                                        ));

            _projectEvents.AddRange(root.conf_override.Where(x => x.Key == "conf_displayMenuLeft").Select(
                                        x => new MenuDisplayHiddenLeft()
                                        ));

            _scrollEvents.AddRange(root.scrollitems.OrderBy(x => x.order).Select(x => new ScrollItemAdded
            {
                Name  = x.name,
                Index = x.order,
                Id    = x.id.ToString()
            }));

            _compositionEvents.Add(new ClearCompositionEvent());

            _compositionEvents.Add(
                new CompositionCreated
            {
                Conf        = root.conf_identifier,
                Scroll      = root.scrollitems_identifier,
                Environment = root.environment_identifier,
                Name        = root.composition.name,
                Id          = root.composition.id.ToString(),
                Time        = root.composition.created,
                User        = root.composition.user_id,
                UserName    = root.composition.username
            });
        }
        public ChiaDetails GettingCHIAIssues()
        {
            Dictionary <string, string> CommentDict = new Dictionary <string, string>();

            ViewBag.From         = from;
            ViewBag.To           = to;
            ViewBag.DeptList     = DeptList;
            ViewBag.SelectedDept = SelectedDept;
            string teams = "(";

            for (int k = 0; k < SelectedDept.Length; k++)
            {
                if (SelectedDept[k] != null)
                {
                    if (k > 0)
                    {
                        teams = teams + " OR ";
                    }
                    teams = teams + "\"Originating Team\" ~ " + SelectedDept[k];
                }
            }
            teams = teams + ")";
            string     url         = "https://jira3.cerner.com/rest/api/2/search?jql=project = CHIA AND issuetype = Assessment AND createdDate >=" + "'" + from + "'" + " AND createdDate<=" + "'" + to + "'" + " AND Assessment = \"CHIA Required\" AND status != Reviewed AND " + teams + " &maxResults=1000";
            WebRequest myReq       = WebRequest.Create(url);
            string     credentials = user + ":" + pwd;

            myReq.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials));
            WebResponse  wr            = myReq.GetResponse();
            Stream       receiveStream = wr.GetResponseStream();
            StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string       content       = reader.ReadToEnd();

            Rootobjectdetails = JsonConvert.DeserializeObject <Rootobject>(content);
            getComments(ref CommentDict);
            listIssues = new List <ChiaIssueDetails>();
            for (int i = 0; i < Rootobjectdetails.issues.Length; i++)
            {
                Dictionary <string, string> CRList = new Dictionary <string, string>();
                chiaobj                    = new ChiaIssueDetails();
                chiaobj.key                = Rootobjectdetails.issues[i].key;
                chiaobj.summary            = Rootobjectdetails.issues[i].fields.summary.ToString();
                chiaobj.createdDate        = Rootobjectdetails.issues[i].fields.created.Date.ToShortDateString();
                chiaobj.status             = Rootobjectdetails.issues[i].fields.status.name.ToString();
                chiaobj.CHIA_Id            = Rootobjectdetails.issues[i].fields.customfield_13331 == null ? "NA" : Rootobjectdetails.issues[i].fields.customfield_13331.ToString();
                chiaobj.compliance_Analyst = Rootobjectdetails.issues[i].fields.customfield_13310 == null ? "NA" : Rootobjectdetails.issues[i].fields.customfield_13310.displayName.ToString();
                chiaobj.age                = (int)Math.Floor((DateTime.Now - Rootobjectdetails.issues[i].fields.created.Date).TotalDays);
                getremotelinks(chiaobj.key.ToString(), ref CRList);

                var results = CommentDict.Where(x => x.Key == chiaobj.key).FirstOrDefault();
                if (results.Key != null)
                {
                    chiaobj.comment = results.Value;
                }
                else
                {
                    createDatabaseEntry(chiaobj.key);
                }

                if (CRList.Count == 0)
                {
                    chiaobj.CHIA_CR = "";
                    chiaobj.CR_url  = "";
                }
                else
                {
                    foreach (var obj in CRList)
                    {
                        chiaobj.CHIA_CR = obj.Key;
                        chiaobj.CR_url  = obj.Value;
                    }
                }
                listIssues.Add(chiaobj);
            }
            chia           = new ChiaDetails();
            listIssues     = listIssues.OrderByDescending(o => o.status).ThenBy(o => o.createdDate).ToList();
            chia.issueInfo = listIssues;
            return(chia);
        }
        /// <summary>
        /// This Method Is for The Intent And Entity which it gets from the luis it will maps according to that
        /// </summary>
        /// <param name="context"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            try
            {
                Rootobject rootobject = new Rootobject();
                //LuisData Luisdata = new LuisData();
                string BotResponseMessage;

                var Entity   = string.Empty;
                var activity = await result as Activity;

                var Userresponse = activity.Text;
                rootobject = await LuisData.ReturnLuisData(Userresponse);

                if (Userresponse.Equals("ChartsTesting", StringComparison.InvariantCultureIgnoreCase))
                {
                    string reply = string.Empty;

                    HttpClient     hclient        = new HttpClient();
                    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://*****:*****@"
                    
             {{
	""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
	""type"": ""AdaptiveCard"",
	""version"": ""1.0"",
	""body"": [
		{{
			""type"": ""Container"",
			""items"": [
				{{
					""type"": ""ColumnSet"",
					""columns"": [
						{{
							""type"": ""Column"",
							""width"": ""auto"",
							""items"": [
								{{  
                            ""type"": ""Image"",
                            ""url"": ""{url}"",
                            ""altText"":""{Userresponse}"",
                            ""size"": ""Stretch"",
								}}
							]
						}},
					]
				}}
			]
		}},
	],
	""actions"": [
		{{
			""type"": ""Action.Showcard"",
			""title"": ""Set due date"",
			""card"": {{
				""type"": ""AdaptiveCard"",
				""body"": [
					{{
						    ""type"": ""Image"",
                            ""url"": ""{MessagesController.chartUrl}"",
                            ""altText"":""{Userresponse}"",
                            ""size"": ""Stretch"",

					}},				
				],
			
			}}
		}},
	
	]
}}")
                    });
                    await context.PostAsync(message);

                    context.Wait(MessageReceivedAsync);



                    //-----------------------------------------------------------------------
//                       message.Attachments.Add(new Attachment()
//                    {
//                        ContentType = "application/vnd.microsoft.card.adaptive",
//                        Content = JObject.Parse($@"
//                 {{
//                ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
//              ""type"": ""AdaptiveCard"",
//              ""version"": ""1.0"",
//              ""body"": [
//                   {{
//                            ""type"": ""TextBlock"",
//                            ""text"": ""TOTAL GROWTH for in 2017 by VIEW""
//                        }},
//                        {{
//                            ""type"": ""Image"",
//                            ""url"": ""{MessagesController.chartUrl}"",
//                            ""altText"":""Not Loaded"",
//                            ""size"": ""Stretch"",
//                            ""horizontalAlignment"": ""right""
//                                }},
//            ],

//}}")
//                    });



                    //--------------------------------------------------------------------
                    //Random r = new Random();
                    //var CardAttachment = LuisData.CreateAdaptiveCardAttachment(this._cards[r.Next(this._cards.Length)]);
                    //var reply = context.MakeMessage();
                    //reply.Attachments = new List<Attachment>() { CardAttachment };
                    //await context.PostAsync(reply,CancellationToken.None);
                    //-------------------------------------------------------------------------------


                    //                    IMessageActivity messageActivity = context.MakeMessage();
                    //                    messageActivity.Attachments.Add(new Attachment()
                    //                    {
                    //                        ContentType = "application /vnd.microsoft.card.adaptive",
                    //                        Content = JObject.Parse(@"
                    //                      {

                    //                ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
                    //              ""type"": ""AdaptiveCard"",
                    //              ""version"": ""1.0"",
                    //              ""body"": [
                    //                     {
                    //                      ""type"": ""Column"",
                    //                      ""width"": ""auto"",
                    //                        ""items"": [
                    //                          {
                    //                            ""type"": ""TextBlock"",
                    //                            ""text"": ""This Is The Bar Graph""
                    //                        },
                    //                        {
                    //                            ""type"": ""Image"",
                    //                            ""url"":""data: image/png; base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAD6CAYAAAB9LTkQAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABWWSURBVHhe7d3bceNYlgVQlQ9pQJmi + aNBNGNMoC8yoj7qVyaMBxyCD5FUQrgbWRDyJs5aESe6RFGgtEmdu4Oq7n45AgCwKAULAGBhChYAwMIULACAhSlYAAALU7AAABamYAEALEzBAgBYmIIFALAwBQsAYGEKFgDAwhQsAICFKVgAAAtTsAAAFqZgAQAsTMECAFiYggUAsDAF6zd5fX09vry8 / DQ / fvw4 / vPPP8YYY8xm599//72ehtulYHVmKFm0Db+gtMmpTUYZOWXklKmQk9O8MwpWxhLLyKlNRhk5ZeSUqZCT07wzClbGEsvIqU1GGTll5JSpkJPTvDMKVsYSy8ipTUYZOWXklKmQk9O8MwpWxhLLyKlNRhk5ZeSUqZCT07wzClbGEsvIqU1GGTll5JSpkJPTvDMKVsYSy8ipTUYZOWXklKmQk9O8MwpWxhLLyKlNRhk5ZeSUqZCT07wzClbGEsvIqU1GGTll5JSpkJPTvDMKVsYSy8ipTUYZOWXklKmQk9O8MwpWxhLLyKlNRhk5ZeSUqZCT07wzClbGEsvIqU1GGTll5JSpkJPTv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9x8u14v15jp6evuj9/3z7hyTk/XPXm8xsPnPr6P8823x7x/H6db79/3H3mN76NgTRqevOelf3tyhifqctv9F+Lp/p9fuNfbH5/Qvq/Roy9+rq55Dc12eow/52f8DTnNufZwuFzv+3gAD4fL7Rr3m4cD6naN26F10ss1Znm8xmNOnf+Mq+T0nM3j62X7v2tfXOObKFgAAAtTsAAAFqZgAQAsTMECAFiYggUAsDAFCwBgYQoWAMDCFCwAgIUpWAAAC1OwAAAWpmABACxMwQIAWJiCBQCwMAULAGBhChYAwMIULACAhSlYAAALU7AAABZ1PP4/5ZvBAnB5uW0AAAAASUVORK5CYII="",
                    //                            ""spacing"": ""none""
                    //                        }
                    //      ]
                    //    }
                    //]
                    //                }")
                    //                    });

                    //                    await context.PostAsync(messageActivity);
                    //                    context.Wait(MessageReceivedAsync);


                    //------------------------------------------------------------------------------------

                    //AdaptiveCard adaptivecard = new AdaptiveCard()
                    //{
                    //    Body = new List<CardElement>()
                    //    {
                    //        new Container()
                    //{
                    //   // speak = " < s > hello!</ s >< s > are you looking for a flight or a hotel ?</ s > ",
                    //    Items =  new List<CardElement>()
                    //    {
                    //        new ColumnSet()
                    //        {
                    //            Columns = new List<Column>()
                    //            {
                    //                new Column()
                    //                {
                    //                    Size = ColumnSize.Auto,
                    //                    Items = new List<CardElement>()
                    //                    {
                    //                        new Image()
                    //                        {
                    //                            Url = MessagesController.chartUrl,
                    //                            Size = ImageSize.Stretch,
                    //                            style = imagestyle.normal
                    //                        }
                    //                    }
                    //                },
                    //             }
                    //         }
                    //    }
                    //}
                    //    }
                    //};

                    //attachment attachment = new attachment()
                    //{
                    //    contenttype = adaptivecard.contenttype,
                    //    content = adaptivecard
                    //};

                    //var reply = context.makemessage();
                    //reply.attachments.add(attachment);
                    //await context.postasync(reply, cancellationtoken.none);



                    //--------------------------------------------------------------------------------------------------------


                    //string position = "right";
                    //var replymessage = context.MakeMessage();

                    //HeroCard plCard = new HeroCard()
                    //{
                    //    Images = new List<CardImage> { new CardImage("<img style="+"width:100%; max-height:100%;"+"src="+MessagesController.chartUrl+" />") }
                    //};
                    //replymessage.Text = string.Empty;
                    //replymessage.AttachmentLayout = AttachmentLayoutTypes.List;
                    //replymessage.Attachments = new List<Microsoft.Bot.Connector.Attachment>();
                    //Microsoft.Bot.Connector.Attachment plAttachment = plCard.ToAttachment();
                    //replymessage.Attachments.Add(plAttachment);
                    //await context.PostAsync(replymessage);
                    //return replyActivity;
                }


                //var card = new AdaptiveCard();
                //card.Body.Add(new Image()
                //{
                //    Url = MessagesController.chartUrl,
                //    Type = "Image",
                //    AltText = "sorry NotLoaded"

                //});
                //Attachment attachment = new Attachment()
                //{
                //    ContentType = AdaptiveCard.ContentType,
                //    Content = card
                //};
                //replymessage.Attachments.Add(attachment);
                //    await context.PostAsync(replymessage);


                //----------------------------------------------------------------------------------
                //var replymessage = context.MakeMessage();
                //var herocard = new HeroCard
                //{
                //    Images=new List<CardImage> { new CardImage("<img src=" + MessagesController.chartUrl + " alt=" + "Image Not Loaded" + " width=" + "500" + " height=" + "600" + ">") }
                //    //Buttons = new List<CardAction> { new CardAction(ActionTypes.ImBack, "Canada", value: "i want to book a meeting room In Canada"), new CardAction(ActionTypes.ImBack, "UK", value: "i want to book a meeting room In UK") }
                //};
                //replymessage.Attachments.Add(herocard.ToAttachment());
                //Logging.ConversationLogg(context.Activity.From.Name, activity.Text, replymessage.ToString(), DateTime.Now, context.Activity.ChannelId);
                //await context.PostAsync(replymessage);

                //-----------------------------------------------------

                if (rootobject.entities != null && rootobject.entities.Length != 0)
                {
                    if (rootobject.topScoringIntent.intent.Equals("RealEstateMeetingRoomReservationBook", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities[0].entity.Equals("Canada", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        Entity             = rootobject.entities[0].entity;
                        BotResponseMessage = PostResponse.GetResponseFromBotForDynamicQuestions(Intent, Entity);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);

                        //await context.PostAsync(MessagesController.Conversationid);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("RealEstateMeetingRoomReservationBook", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities[0].entity.Equals("UK", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        Entity             = rootobject.entities[0].entity;
                        BotResponseMessage = PostResponse.GetResponseFromBotForDynamicQuestions(Intent, Entity);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("ItTicketRaising", StringComparison.InvariantCultureIgnoreCase) && (rootobject.entities[0].type.Equals("Category", StringComparison.InvariantCultureIgnoreCase) || rootobject.entities[0].type.Equals("Subcategory", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        ActivityValue = Userresponse;
                        context.Call(new GenerateItTicket(), AfterChoosencategory);
                    }
                    else
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        BotResponseMessage = PostResponse.GetResponseFromBotForStaticQuestions(Intent);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                }
                else
                {
                    if (rootobject.topScoringIntent.intent.Equals("RealEstateMeetingRoomReservationBook", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        var replymessage = context.MakeMessage();
                        var herocard     = new ThumbnailCard
                        {
                            Text    = "Please Book the rooms in Below Locations Only",
                            Buttons = new List <CardAction> {
                                new CardAction(ActionTypes.ImBack, "Canada", value: "i want to book a meeting room In Canada"), new CardAction(ActionTypes.ImBack, "UK", value: "i want to book a meeting room In UK")
                            }
                        };
                        replymessage.Attachments.Add(herocard.ToAttachment());
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, replymessage.ToString(), DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(replymessage);
                    }

                    else if (rootobject.topScoringIntent.intent.Equals("Register", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        Intent = rootobject.topScoringIntent.intent;
                        context.Call(new QuestionsDialog(), AfterChoosencategory);

                        //  questions = PostResponse.Questions(rootobject.topScoringIntent.intent);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("TicketsCount", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        string SpecificUser = context.Activity.From.Name;
                        Tickets = PostResponse.TicketsLists(SpecificUser);
                        if (Tickets.Count != 0)
                        {
                            for (int i = 1; i <= Tickets.Count; i++)
                            {
                                TicketsGenerated += "<b>Ticket " + i + "</b> :- " + "  category is - " + Tickets[i - 1].IssueCategory + " ,Issue facing With - " + Tickets[i - 1].IssuefacingWith + " ,Description by you - " + Tickets[i - 1].IssueDescription + " ,  Time " + Tickets[i - 1].GeneratingTime + "<br/>";
                            }
                            var ticketsdisplaycard = context.MakeMessage();
                            var Herocard           = new HeroCard
                            {
                                Text = TicketsGenerated
                            };
                            ticketsdisplaycard.Attachments.Add(Herocard.ToAttachment());
                            Tickets.Clear();
                            TicketsGenerated = string.Empty;
                            await context.PostAsync(ticketsdisplaycard);
                        }
                        else
                        {
                            await context.PostAsync(" Sorry " + SpecificUser + ", You did not Raised Any Tickets Yet");
                        }
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("RealEstateReceptionRegister", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        Entity             = "";
                        BotResponseMessage = PostResponse.GetResponseFromBotForDynamicQuestions(Intent, Entity);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("RealEstateShuttleBusSchedule", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        Entity             = "";
                        BotResponseMessage = PostResponse.GetResponseFromBotForDynamicQuestions(Intent, Entity);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("TravelBookITBook", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        Entity             = "";
                        BotResponseMessage = PostResponse.GetResponseFromBotForDynamicQuestions(Intent, Entity);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("ItTicketRaising", StringComparison.InvariantCultureIgnoreCase) && rootobject.entities.Length == 0)
                    {
                        ActivityValue = Userresponse;
                        context.Call(new GenerateItTicket(), AfterChoosencategory);
                    }
                    else if (rootobject.topScoringIntent.intent.Equals("VisitorBadgeRequest", StringComparison.InvariantCultureIgnoreCase))
                    {
                        ActivityValue = Userresponse;
                        context.Call(new VisitorBadgeDialog(), AfterChoosencategory);
                    }
                    else
                    {
                        Intent             = rootobject.topScoringIntent.intent;
                        BotResponseMessage = PostResponse.GetResponseFromBotForStaticQuestions(Intent);
                        //BotResponseMessage = BotResponseMessage.Replace("$", System.Environment.NewLine);
                        BotResponseMessage = BotResponseMessage.Replace("#", context.Activity.From.Name);
                        Logging.ConversationLogg(context.Activity.From.Name, activity.Text, BotResponseMessage, DateTime.Now, context.Activity.ChannelId);
                        await context.PostAsync(BotResponseMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.errorloginfo(ex.Message, DateTime.Now);
                await context.PostAsync(ex.Message);
            }
        }
Пример #26
0
        static void Main(string[] args)
        {
            Rootobject results = GetJsonForToday();

            TakeImagesFromResults(results);
        }
        public async void DatabaseGet()
        {
            I00.IsEnabled             = false;
            I10.IsEnabled             = false;
            I20.IsEnabled             = false;
            I01.IsEnabled             = false;
            I11.IsEnabled             = false;
            I21.IsEnabled             = false;
            I02.IsEnabled             = false;
            I12.IsEnabled             = false;
            I22.IsEnabled             = false;
            I03.IsEnabled             = false;
            I13.IsEnabled             = false;
            I23.IsEnabled             = false;
            I30.IsEnabled             = false;
            I31.IsEnabled             = false;
            I32.IsEnabled             = false;
            I33.IsEnabled             = false;
            PlayAgainButton.IsEnabled = false;
            Rootobject          result = null;
            HttpResponseMessage task   = await client.GetAsync("http://test.gardengnome.info/api/services/app/Plant/GetAll?SkipCount=0&MaxResultCount=999");

            var jsonString = task.Content.ReadAsStringAsync();

            jsonString.Wait();
            result = JsonConvert.DeserializeObject <Rootobject>(jsonString.Result);


            for (var i = 0; i < result.result.items.Length; i++)
            {
                if (i != 10)
                {
                    if (result.result.items[i].plantImage.Length > 0)
                    {
                        string plant = ("http://cdn.gardengnome.info/images/plant/" + result.result.items[i].plantImage[0].imageName);
                        PlantList.Add(plant);
                        System.Diagnostics.Debug.WriteLine(i + "  " + result.result.items[i].commonName);
                    }
                }
            }
            PlantsImageArr = PlantList.ToArray();
            System.Diagnostics.Debug.WriteLine("PlantsImageArr Length: " + PlantsImageArr.Length);
            Pair1                     = PlantsImageArr[0];
            Pair2                     = PlantsImageArr[1];
            Pair3                     = PlantsImageArr[2];
            Pair4                     = PlantsImageArr[3];
            Pair5                     = PlantsImageArr[4];
            Pair6                     = PlantsImageArr[5];
            Pair7                     = PlantsImageArr[6];
            Pair8                     = PlantsImageArr[7];
            I00.IsEnabled             = true;
            I10.IsEnabled             = true;
            I20.IsEnabled             = true;
            I01.IsEnabled             = true;
            I11.IsEnabled             = true;
            I21.IsEnabled             = true;
            I02.IsEnabled             = true;
            I12.IsEnabled             = true;
            I22.IsEnabled             = true;
            I03.IsEnabled             = true;
            I13.IsEnabled             = true;
            I23.IsEnabled             = true;
            I30.IsEnabled             = true;
            I31.IsEnabled             = true;
            I32.IsEnabled             = true;
            I33.IsEnabled             = true;
            PlayAgainButton.IsEnabled = true;
        }
Пример #28
0
        private void Sc_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            lock (o)
            {
                if (!IsLoading)
                {
                    if (sc.VerticalOffset == sc.ScrollableHeight)
                    {
                        IsLoading = true;
                        Task.Factory.StartNew(async() =>
                        {
                            await Task.Delay(1000);
                            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                            {
                                if (count % 4 != 0 || templist.Count / 5 > count)
                                {
                                    templist1.Clear();
                                    for (int i = count * 5; i < (count * 5) + 5; i++)
                                    {
                                        templist1.Add(templist[i]);
                                    }
                                    count++;
                                }
                                else
                                {
                                    string json = await NetWork.HttpRequest.GetVideo((templist.Count / 20) + 1);
                                    json        = json.Replace("\\n", "");
                                    json        = json.Replace(" ", "");
                                    if (!string.IsNullOrWhiteSpace(json))
                                    {
                                        VideoResult = JsonConvert.DeserializeObject <Rootobject>(json);
                                        switch (VideoResult.showapi_res_code)
                                        {
                                        case 0:
                                            {
                                                for (int i = 0; i < 20; i++)
                                                {
                                                    templist.Add(VideoResult.showapi_res_body.pagebean.contentlist[i]);
                                                }
                                                templist1.Clear();
                                                for (int i = (count * 5); i < (count * 5) + 5; i++)
                                                {
                                                    templist1.Add(templist[i]);
                                                }
                                                count++;
                                                viewmodel.VideoResult = templist1;
                                                break;
                                            }

                                            #region 错误码
                                        case -1:
                                            {
                                                var dialog = new MessageDialog("系统调用错误", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -2:
                                            {
                                                var dialog = new MessageDialog("可调用次数或金额为0", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -3:
                                            {
                                                var dialog = new MessageDialog("读取超时", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -4:
                                            {
                                                var dialog = new MessageDialog("服务端返回数据解析错误", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -5:
                                            {
                                                var dialog = new MessageDialog("后端服务器DNS解析错误", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -6:
                                            {
                                                var dialog = new MessageDialog("服务不存在或未上线", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1000:
                                            {
                                                var dialog = new MessageDialog("系统维护", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1002:
                                            {
                                                var dialog = new MessageDialog("showapi_appid字段必传", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1003:
                                            {
                                                var dialog = new MessageDialog("showapi_sign字段必传", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1004:
                                            {
                                                var dialog = new MessageDialog("签名sign验证有误", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1005:
                                            {
                                                var dialog = new MessageDialog("showapi_timestamp无效", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1006:
                                            {
                                                var dialog = new MessageDialog("app无权限调用接口 ", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1007:
                                            {
                                                var dialog = new MessageDialog("没有订购套餐 ", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1008:
                                            {
                                                var dialog = new MessageDialog("服务商关闭对您的调用权限 ", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1010:
                                            {
                                                var dialog = new MessageDialog("找不到您的应用", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1011:
                                            {
                                                var dialog = new MessageDialog("子授权app_child_id无效", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1012:
                                            {
                                                var dialog = new MessageDialog("子授权已过期或失效", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }

                                        case -1013:
                                            {
                                                var dialog = new MessageDialog("子授权ip受限", "异常提示");
                                                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                                                var a = await dialog.ShowAsync();
                                                break;
                                            }
                                            #endregion
                                        }
                                    }
                                }
                                viewmodel.VideoResult = templist1;
                                await Task.Delay(300);
                                sc.ChangeView(null, 30, null);
                                IsLoading = false;
                            });
                        });
                    }
                    if (!e.IsIntermediate)
                    {
                        if (sc.VerticalOffset == 0.0)
                        {
                            IsLoading = true;
                            Task.Factory.StartNew(async() =>
                            {
                                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                                {
                                    if (count != 1)
                                    {
                                        templist1.Clear();
                                        for (int i = (count - 2) * 5; i < ((count - 2) * 5) + 5; i++)
                                        {
                                            templist1.Add(templist[i]);
                                        }
                                        count--;
                                    }
                                    else
                                    {
                                        await FirstStep();
                                        IsLoading = false;
                                        return;
                                    }
                                    viewmodel.VideoResult = templist1;
                                    await Task.Delay(300);
                                    sc.ChangeView(null, 30, null);
                                    IsLoading = false;
                                });
                            });
                        }
                    }
                }
            }
        }
Пример #29
0
        public IActionResult Search(string country, string what, string where, int page = 1)
        {
            //Encodes any special characters in the search string, then gets data from the API and puts it in a results list
            string encodedWhat;

            if (what.Contains('%'))
            {
                encodedWhat = what;
            }
            else
            {
                encodedWhat = WebUtility.UrlEncode(what);
            }

            string encodedWhere;

            if (where.Contains('%'))
            {
                encodedWhere = where;
            }
            else
            {
                encodedWhere = WebUtility.UrlEncode(where);
            }
            Rootobject    r          = jd.SearchJobs(country.ToLower(), page, encodedWhat, encodedWhere);
            List <Result> jobResults = r.results.ToList();

            //If user is logged in, hide results the user already has saved in their tracker
            if (User.Identity.IsAuthenticated)
            {
                //Gets the Link property of all jobs the user has saved, remove any null values
                List <string> dbJobLinks = _context.Jobs.Where(x => x.UserId == User.FindFirst(ClaimTypes.NameIdentifier).Value).Select(x => x.Link).ToList();
                dbJobLinks = dbJobLinks.Where(x => x != null).ToList();

                List <Result> duplicates = new List <Result>();

                //Adds job results from API to a duplicates list if their link matches one in the DB
                foreach (Result result in jobResults)
                {
                    if (dbJobLinks.Any(x => TextHelper.CompareJobUrl(x, result.redirect_url)))
                    {
                        duplicates.Add(result);
                    }
                }

                //Removes duplicates from results to display
                foreach (Result rd in duplicates)
                {
                    jobResults.Remove(rd);
                }
            }


            //Stores query parameters in TempData so user can page through results without having to search again
            TempData["country"] = country;
            TempData["page"]    = page;
            TempData["what"]    = what;
            TempData["where"]   = where;

            return(View(jobResults));
        }
Пример #30
0
        private async Task FirstStep()
        {
            try
            {
                templist  = new ObservableCollection <Contentlist>();
                templist1 = new ObservableCollection <Contentlist>();
                count     = 1;
                string json;
                json = await NetWork.HttpRequest.GetVideo(1);

                json = json.Replace("\\n", "");
                json = json.Replace(" ", "");
                if (!string.IsNullOrWhiteSpace(json))
                {
                    VideoResult = JsonConvert.DeserializeObject <Rootobject>(json);
                    switch (VideoResult.showapi_res_code)
                    {
                    case 0:
                    {
                        templist = VideoResult.showapi_res_body.pagebean.contentlist;
                        for (int i = 0; i < 5; i++)
                        {
                            templist1.Add(templist[i]);
                        }
                        viewmodel.VideoResult = templist1;
                        break;
                    }

                        #region 错误码
                    case -1:
                    {
                        var dialog = new MessageDialog("系统调用错误", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -2:
                    {
                        var dialog = new MessageDialog("可调用次数或金额为0", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -3:
                    {
                        var dialog = new MessageDialog("读取超时", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -4:
                    {
                        var dialog = new MessageDialog("服务端返回数据解析错误", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -5:
                    {
                        var dialog = new MessageDialog("后端服务器DNS解析错误", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -6:
                    {
                        var dialog = new MessageDialog("服务不存在或未上线", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1000:
                    {
                        var dialog = new MessageDialog("系统维护", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1002:
                    {
                        var dialog = new MessageDialog("showapi_appid字段必传", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1003:
                    {
                        var dialog = new MessageDialog("showapi_sign字段必传", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1004:
                    {
                        var dialog = new MessageDialog("签名sign验证有误", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1005:
                    {
                        var dialog = new MessageDialog("showapi_timestamp无效", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1006:
                    {
                        var dialog = new MessageDialog("app无权限调用接口 ", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1007:
                    {
                        var dialog = new MessageDialog("没有订购套餐 ", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1008:
                    {
                        var dialog = new MessageDialog("服务商关闭对您的调用权限 ", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1010:
                    {
                        var dialog = new MessageDialog("找不到您的应用", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1011:
                    {
                        var dialog = new MessageDialog("子授权app_child_id无效", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1012:
                    {
                        var dialog = new MessageDialog("子授权已过期或失效", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }

                    case -1013:
                    {
                        var dialog = new MessageDialog("子授权ip受限", "异常提示");
                        dialog.Commands.Add(new UICommand("确定", cmd => { }));
                        var a = await dialog.ShowAsync();

                        break;
                    }
                        #endregion
                    }
                    await Task.Delay(1000);

                    sc.ChangeView(null, 30, null);
                }
                else
                {
                    await Task.Delay(1000);

                    sc.ChangeView(null, 30, null);
                    return;
                }
            }
            catch (HttpRequestException)
            {
                var dialog = new MessageDialog("网络出现异常", "异常提示");
                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                await dialog.ShowAsync();

                return;
            }
            catch (Exception)
            {
                await Task.Delay(1000);

                sc.ChangeView(null, 30, null);
            }
        }
 public override List <Video> extactData(Rootobject result)
 {
     return(result.videos.ToList());
 }
Пример #32
0
 public static Response CreatePackageFileFromJSON(Rootobject model)
 {
     return null;
 }