Ejemplo n.º 1
0
        public static void insertHashTomainFileContainer(string fileNamePart)
        {

            FTDataSet ds = new FTDataSet();
            mainFileContainer_for_updateNameTableAdapter files = new mainFileContainer_for_updateNameTableAdapter();
            files.Fill(ds.mainFileContainer_for_updateName);
            try
            {
                foreach (DataRow dr in ds.mainFileContainer_for_updateName.Rows)
                {
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString()).FirstOrDefault();
                    string _result = null;
                    if (match != null)
                    {
                        _result = match.UNOM + match.Name + match.Date + "_" + dr["Hash"].ToString() + "." + match.Extension;
                        if (dr["name"].ToString() != _result)
                        { dr["name"] = _result; }
                    }
                };
            }
            finally
            {
                if (ds.mainFileContainer_for_updateName.HasErrors)
                { }
                else // If no errors, AcceptChanges.

                        if (ds.mainFileContainer_for_updateName.GetChanges() != null)
                {
                    files.Update(ds.mainFileContainer_for_updateName);
                }
            }
        }
Ejemplo n.º 2
0
        public static void mainFileContainer_insertFoto()
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            mainFileContainer_for_updateNameTableAdapter f4 = new mainFileContainer_for_updateNameTableAdapter();
            string _name = "_фото";
            f4.Fill(ds.mainFileContainer_for_updateName);
            try
            {
                var rr = ds.mainFileContainer_for_updateName.Where(selector =>
                  {
                      MATCFileNameFullExtensoinResult match1 = RegEx.GetMATCFileNameFullExtensoinResult(selector["name"].ToString()).FirstOrDefault();
                      if (match1 != null && string.IsNullOrEmpty(match1.Name)) { return true; } else { return false; };
                  });
                foreach (DataRow dr in ds.mainFileContainer_for_updateName.Rows)
                {
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString()).FirstOrDefault();
                    if (match != null && string.IsNullOrEmpty(match.Name))
                    {
                        string _result = null;
                        _result = match.UNOM + _name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension;
                        if (dr["Name"].ToString() != _result)
                        {
                            dr.SetField<string>("Name", _result);
                        };
                    };
                }
            }
            finally
            {
                if (ds.mainFileContainer_for_updateName.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (ds.mainFileContainer_for_updateName.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(ds.mainFileContainer_for_updateName);
                }

            }
        }
Ejemplo n.º 3
0
        public static void mainFileContainer_normalizationName()
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            CommonTableAdapter cta = new CommonTableAdapter();
            mainFileContainer_for_updateNameTableAdapter f4 = new mainFileContainer_for_updateNameTableAdapter();
            f4.Connection.ConnectionString = "Data Source=MAKSIMOV;Initial Catalog=GBUMATC;Persist Security Info=True;Connection Timeout=50000000;User ID=Бушмакин;Password=453459";
            FTDataSet.mainFileContainer_for_updateNameDataTable wtable = ds.mainFileContainer_for_updateName;
            f4.Fill(wtable);
            try
            {
                /*var rr = wtable.Where(selector =>
                {
                    MATCFileNameFullExtensoinResult match1 = RegEx.GetMATCFileNameFullExtensoinResult(selector["name"].ToString()).FirstOrDefault();
                    if (match1 != null && string.IsNullOrEmpty(match1.Name)) { return true; } else { return false; };
                }).ToList();*/
                foreach (DataRow dr in wtable.Rows)
                {
                    string _result = null;
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString().Trim()).FirstOrDefault();
                    if (match != null)
                    {
                        Console.WriteLine(dr["name"].ToString() + " добавляется");
                        if (string.IsNullOrEmpty(match.Name))
                        { _result = match.UNOM + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        else
                        { _result = match.UNOM + match.Name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        if (dr["Name"].ToString() != _result)
                        {
                            dr.SetField<string>("Name", _result);
                            try
                            {
                                //cta.Update_mainFileContainer_Query(_result, dr["path_locator"].ToString());
                                Console.WriteLine(_result);
                            }
                            catch (Exception e)
                            { Console.WriteLine(_result + e.Message); }
                        };
                    }
                    else
                    {
                        //_result = dr["UNOM"].ToString() + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + dr["file_type"].ToString();
                        Console.WriteLine(dr["name"].ToString() + " херня-с");
                        //cta.Update_ActFiles_names_Query(_result, dr["path_locator"].ToString());
                        //dr.SetField<string>("Name", _result);
                    };
                }
            }
            finally
            {
                if (wtable.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (wtable.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(wtable);
                }

            }
        }