Esempio n. 1
0
        public virtual void Shutdown()
        {
            if (__nodes != null)
            {
                Node instance;
                foreach (KeyValuePair <int, Node> pair in __nodes)
                {
                    instance = pair.Value;
                    if (instance is Node)
                    {
                        if (instance._onDestroy != null)
                        {
                            instance._onDestroy();
                        }
                    }

                    if (instance != null)
                    {
                        Destroy(instance.gameObject);
                    }
                }

                __nodes.Clear();
            }

            if (__client != null)
            {
                //__client.Disconnect();
                __client.Shutdown();
                __client = null;
            }
        }
 public void Reset()
 {
     packed_textures = null;
     texs.Clear();
     rects.Clear();
     requested_characters = "";
 }
 public void InitializeDOMPools(IDictionary <int, IDOMPool> dictDOMPools)
 {
     m_dict.Clear();
     foreach (KeyValuePair <int, IDOMPool> kvp in dictDOMPools)
     {
         m_dict.Add(kvp.Value.ID, new DisturbTransferFromPool(kvp.Value.ID, kvp.Value.Name));
     }
 }
 public void Prepare(System.Func <char, TTFTextTexturePortion> texgen)
 {
     texs.Clear();
     foreach (char c in requested_characters)
     {
         texs.Add(c, texgen(c));
     }
     UpdatePackedTexture();
 }
Esempio n. 5
0
        private void menuDisconnect_Click(object sender, EventArgs e)
        {
            lstViewer.Items.Clear();
            Objects.Clear();

            sc.Close();

            menuConnect.Visible    = true;
            menuDisconnect.Visible = false;
        }
Esempio n. 6
0
 void OnDestroy()
 {
     if (_TextsMap != null)
     {
         _TextsMap.Clear();
     }
     if (_AudioMap != null)
     {
         _AudioMap.Clear();
     }
 }
        void JButton2_Click(object sender, EventArgs e)
        {
            WebFrame.Data.JTable tab1 = new WebFrame.Data.JTable("HIGHTRAINPROFILE");
            System.Collections.Generic.List <WebFrame.Data.SearchField> condition =
                new System.Collections.Generic.List <WebFrame.Data.SearchField>();
            System.Collections.Generic.Dictionary <String, object> data1 =
                new System.Collections.Generic.Dictionary <string, object>();
            int i = 0;

            String[] arr1 = "Weight".Split(',');
            foreach (RepeaterItem item in this.Repeater2.Items)
            {
                condition.Clear();
                condition.Add(new WebFrame.Data.SearchField("id", (i + 1) + "", WebFrame.SearchFieldType.NumericType));
                data1.Clear();
                foreach (String m in arr1)
                {
                    TextBox t1 = item.FindControl(m) as TextBox;
                    if (t1 != null)
                    {
                        data1[m] = t1.Text;
                    }
                }
                tab1.EditData(data1, condition);
                i++;
            }


            tab1.Close();
            BusinessRule.HighTrainProfile.SetData();
            WebFrame.Util.JAjax.Alert("提示:更新数据操作成功!");
        }
Esempio n. 8
0
        private void ConstructFromFileCache()
        {
            offsets_.Clear();
            if (System.IO.File.Exists(headerFileName_))
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(headerFileName_))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] headerParts = line.Split(',');
                        if (headerParts.Length == 3)
                        {
                            offsets_[Convert.ToInt32(headerParts[0])] = new MsgDef(
                                Convert.ToInt64(headerParts[1]), Convert.ToInt32(headerParts[2]));
                        }
                    }
                }
            }

            if (System.IO.File.Exists(seqNumsFileName_))
            {
                using (System.IO.StreamReader seqNumReader = new System.IO.StreamReader(seqNumsFileName_))
                {
                    string[] parts = seqNumReader.ReadToEnd().Split(':');
                    if (parts.Length == 2)
                    {
                        cache_.SetNextSenderMsgSeqNum(Convert.ToInt32(parts[0]));
                        cache_.SetNextTargetMsgSeqNum(Convert.ToInt32(parts[1]));
                    }
                }
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string             openIdType     = "Ecdev.plugins.openid.alipay.alipayservice";
            OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);

            if (openIdSettings == null)
            {
                return;
            }
            string value = base.Request.QueryString["alipaytoken"];

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings));
            System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
            sortedDictionary.Add("service", "user.logistics.address.query");
            sortedDictionary.Add("partner", xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText);
            sortedDictionary.Add("_input_charset", "utf-8");
            sortedDictionary.Add("return_url", Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("LogisticsAddress_url")));
            sortedDictionary.Add("token", value);
            System.Collections.Generic.Dictionary <string, string> dictionary = OpenIdFunction.FilterPara(sortedDictionary);
            string value2 = OpenIdFunction.BuildMysign(dictionary, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8");

            dictionary.Add("sign", value2);
            dictionary.Add("sign_type", "MD5");
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            foreach (System.Collections.Generic.KeyValuePair <string, string> current in dictionary)
            {
                stringBuilder.Append(OpenIdFunction.CreateField(current.Key, current.Value));
            }
            sortedDictionary.Clear();
            dictionary.Clear();
            OpenIdFunction.Submit(OpenIdFunction.CreateForm(stringBuilder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8"));
        }
Esempio n. 10
0
 public void Reset()
 {
     nextSenderMsgSeqNum_ = 1;
     nextTargetMsgSeqNum_ = 1;
     messages_.Clear();
     creationTime = DateTime.UtcNow;
 }
        private void UpdateOil()
        {
            WebFrame.Data.JTable tab1 = new WebFrame.Data.JTable("COMMTRAINWEIGHTPROFILE");
            System.Collections.Generic.List <WebFrame.Data.SearchField> condition =
                new System.Collections.Generic.List <WebFrame.Data.SearchField>();
            System.Collections.Generic.Dictionary <String, object> data1 =
                new System.Collections.Generic.Dictionary <string, object>();
            int i = 2;

            String[] arr1 = "Oil".Split(',');
            foreach (RepeaterItem item in this.Repeater2.Items)
            {
                condition.Clear();
                condition.Add(new WebFrame.Data.SearchField("num", i + "", WebFrame.SearchFieldType.NumericType));
                data1.Clear();
                foreach (String m in arr1)
                {
                    TextBox t1 = item.FindControl(m) as TextBox;
                    if (t1 != null)
                    {
                        data1[m] = t1.Text;
                    }
                }
                tab1.EditData(data1, condition);
                i = i + 1;
            }
            tab1.Close();
            BusinessRule.CheXianProfile.SetData();
            WebFrame.Util.JAjax.Alert("提示:更新数据操作成功!");
        }
        //Submit Data
        void button1_Click(object sender, EventArgs e)
        {
            WebFrame.Data.JTable tab1 = new WebFrame.Data.JTable("CHEXIANBIANZHU");
            System.Collections.Generic.List <WebFrame.Data.SearchField> condition =
                new System.Collections.Generic.List <WebFrame.Data.SearchField>();
            System.Collections.Generic.Dictionary <String, object> data1 =
                new System.Collections.Generic.Dictionary <string, object>();
            for (int i = 1; i <= 17; i++)
            {
                condition.Clear();
                condition.Add(new WebFrame.Data.SearchField("id", i + "", WebFrame.SearchFieldType.NumericType));
                data1.Clear();

                TextBox t1 = Rate1.Parent.FindControl("Rate" + i) as TextBox;
                if (t1 != null)
                {
                    data1["Rate"] = t1.Text;
                }


                TextBox t2 = Person1.Parent.FindControl("Person" + i) as TextBox;
                if (t2 != null)
                {
                    data1["Person"] = t2.Text;
                }
                tab1.EditData(data1, condition);
            }
            tab1.Close();
            ChexianBianZhuData.SetData();
            WebFrame.Util.JAjax.Alert("提示:更新数据操作成功!");
        }
Esempio n. 13
0
        void button2_Click(object sender, EventArgs e)
        {
            WebFrame.Data.JTable tab1 = new WebFrame.Data.JTable("COMMTRAINWEIGHTPROFILE");
            System.Collections.Generic.List <WebFrame.Data.SearchField> condition =
                new System.Collections.Generic.List <WebFrame.Data.SearchField>();
            System.Collections.Generic.Dictionary <String, object> data1 =
                new System.Collections.Generic.Dictionary <string, object>();
            int i = 1;

            String[] arr1 = "Speed,YzPrice,RzPrice,SYzPrice,SRzPrice,YwPrice,RwPrice,GRw19KPrice,GRw19TPrice,CaPrice,KdPrice".Split(',');
            foreach (RepeaterItem item in this.Repeater2.Items)
            {
                condition.Clear();
                condition.Add(new WebFrame.Data.SearchField("num", i + "", WebFrame.SearchFieldType.NumericType));
                data1.Clear();
                foreach (String m in arr1)
                {
                    TextBox t1 = item.FindControl(m) as TextBox;
                    if (t1 != null)
                    {
                        data1[m] = t1.Text;
                    }
                }
                tab1.EditData(data1, condition);
                i++;
            }
            tab1.Close();
            BusinessRule.CheXianProfile.SetData();
            WebFrame.Util.JAjax.Alert("提示:更新数据操作成功!");
        }
        void button1_Click(object sender, EventArgs e)
        {
            WebFrame.Data.JTable tab1 = new WebFrame.Data.JTable("PERSONGZ");
            System.Collections.Generic.List <WebFrame.Data.SearchField> condition =
                new System.Collections.Generic.List <WebFrame.Data.SearchField>();
            System.Collections.Generic.Dictionary <String, object> data1 =
                new System.Collections.Generic.Dictionary <string, object>();
            int i = 10;

            String[] arr1 = "Qtfy".Split(',');
            foreach (RepeaterItem item in this.Repeater1.Items)
            {
                condition.Clear();
                condition.Add(new WebFrame.Data.SearchField("num", i + "", WebFrame.SearchFieldType.NumericType));
                data1.Clear();
                foreach (String m in arr1)
                {
                    TextBox t1 = item.FindControl(m) as TextBox;
                    if (t1 != null)
                    {
                        data1[m] = t1.Text;
                    }
                }
                tab1.EditData(data1, condition);
                i++;
            }


            tab1.Close();
            BusinessRule.PersonGZProfile.SetData();
            WebFrame.Util.JAjax.Alert("提示:更新数据操作成功!");
        }
 public void Clear()
 {
     lock (mMethods)
     {
         mMethods.Clear();
     }
 }
Esempio n. 16
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            UInt32 selTaskId = SelectedAppointmentId;

            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                SelectedAppointment = null;
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type))
            {
                task = task.GetNextTask();
            }

            SelectionStart = SelectionEnd;

            AdjustScrollbar();
            Invalidate();
        }
Esempio n. 17
0
 public void Clear()
 {
     strTableName = "";
     strSPName    = "";
     strConditon  = "";
     htData.Clear();
 }
Esempio n. 18
0
 public void Dispose()
 {
     foreach (Client client in ToArray())
     {
         client.Dispose();
     }
     clientList.Clear();
 }
Esempio n. 19
0
        private static void PopulateMemberInfos(StructMapping structMapping, MemberMapping[] memberMappings, System.Collections.Generic.Dictionary <string, MemberInfo> memberInfos)
        {
            memberInfos.Clear();
            for (int i = 0; i < memberMappings.Length; ++i)
            {
                memberInfos[memberMappings[i].Name] = memberMappings[i].MemberInfo;
                if (memberMappings[i].ChoiceIdentifier != null)
                {
                    memberInfos[memberMappings[i].ChoiceIdentifier.MemberName] = memberMappings[i].ChoiceIdentifier.MemberInfo;
                }
                if (memberMappings[i].CheckSpecifiedMemberInfo != null)
                {
                    memberInfos[memberMappings[i].Name + "Specified"] = memberMappings[i].CheckSpecifiedMemberInfo;
                }
            }

            // The scenario here is that user has one base class A and one derived class B and wants to serialize/deserialize an object of B.
            // There's one virtual property defined in A and overrided by B. Without the replacing logic below, the code generated will always
            // try to access the property defined in A, rather than B.
            // The logic here is to:
            // 1) Check current members inside memberInfos dictionary and figure out whether there's any override or new properties defined in the derived class.
            //    If so, replace the one on the base class with the one on the derived class.
            // 2) Do the same thing for the memberMapping array. Note that we need to create a new copy of MemberMapping object since the old one could still be referenced
            //    by the StructMapping of the baseclass, so updating it directly could lead to other issues.
            Dictionary <string, MemberInfo> replaceList = null;
            MemberInfo replacedInfo = null;

            foreach (KeyValuePair <string, MemberInfo> pair in memberInfos)
            {
                if (ShouldBeReplaced(pair.Value, structMapping.TypeDesc.Type, out replacedInfo))
                {
                    if (replaceList == null)
                    {
                        replaceList = new Dictionary <string, MemberInfo>();
                    }

                    replaceList.Add(pair.Key, replacedInfo);
                }
            }

            if (replaceList != null)
            {
                foreach (KeyValuePair <string, MemberInfo> pair in replaceList)
                {
                    memberInfos[pair.Key] = pair.Value;
                }
                for (int i = 0; i < memberMappings.Length; i++)
                {
                    MemberInfo mi;
                    if (replaceList.TryGetValue(memberMappings[i].Name, out mi))
                    {
                        MemberMapping newMapping = memberMappings[i].Clone();
                        newMapping.MemberInfo = mi;
                        memberMappings[i]     = newMapping;
                    }
                }
            }
        }
Esempio n. 20
0
 private void refreshDomain_BT_Click_1(object sender, EventArgs e)
 {
     domainAssemblies.Clear();
     domainClasses.Clear();
     methods.Clear();
     constructors.Clear();
     hierarchyViewer_TN.Nodes.Clear();
     buildTree();
 }
Esempio n. 21
0
 public void Dispose()
 {
     foreach (var pageItems in _items)
     {
         pageItems.Dispose();
     }
     _items.Clear();
     _PageExprReferences?.Clear();
 }
Esempio n. 22
0
        internal void Clear()
        {
            _trapStartIndex = 0;
            _rootObject     = null;
            _underlyingList?.Clear();
            _stringKeys?.Clear();
#if !CF && !PORTABLE
            _objectKeys?.Clear();
#endif
        }
        public RPCInstance Find(Component source, RPCReceiver receiver, Component observed, GameObject[] listOfGameObjects, string rpcName)
        {
            if (_receiver != receiver || !_observed.ReferenceEquals(observed) || _observed.IsDestroyed())
            {
                _receiver = receiver;
                _observed = observed.IsNotDestroyed() ? observed : null;
                _rpcs.Clear();
            }

            RPCInstance rpc;

            if (!_rpcs.TryGetValue(rpcName, out rpc) || rpc.instance.IsNullOrDestroyed())
            {
                rpc            = new RPCInstance(source, receiver, observed as UnityEngine.MonoBehaviour, listOfGameObjects, rpcName, _messageInfoHandle);
                _rpcs[rpcName] = rpc;
            }

            return(rpc);
        }
Esempio n. 24
0
        public void Clear()
        {
            var dic = new System.Collections.Generic.Dictionary <int, string>();

            dic.Add(1, "a");
            dic.Add(2, "b");
            dic.Add(3, "c");
            dic.Clear();

            Assert.AreEqual(0, dic.Count);
        }
Esempio n. 25
0
        public static void UrlParse(System.Collections.Generic.Dictionary <string, string> mctabuff_msg, string EVT)
        {
            mctabuff_msg.Clear(); //clear the dictionary
            List <string> sl = EVT.Split(';').ToList();

            foreach (string s in sl)
            {
                string skey = s.Split('=').FirstOrDefault();
                string sval = s.Split('=').LastOrDefault();
                mctabuff_msg.Add(skey, sval);
            }
        }
Esempio n. 26
0
    public static GenericResponse deleteProduct(int idUser, int idProduct)
    {
        GenericResponse ret = new GenericResponse();

        Dictionary <string, object> parameters = new System.Collections.Generic.Dictionary <string, object>();

        parameters.Add("idUser", idUser);
        parameters.Add("idProducto", idProduct);
        DataSet result;

        try
        {
            result = DataAccess.executeStoreProcedureDataSet("Spr_delete_product", parameters);
            if (null != result)
            {
                //Verificando respuesta
                if ((int)result.Tables[0].Rows[0]["Success"] == 1)
                {
                    string carpeta = string.Empty;
                    parameters.Clear();
                    parameters.Add("idUser", idUser);
                    carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
                    if (!String.IsNullOrEmpty(carpeta))
                    {
                        string PathDocs         = ConfigurationManager.AppSettings["EmpresasFiles"];
                        string inicio           = HttpContext.Current.Server.MapPath(PathDocs);
                        string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;
                        //Si ok Eliminando fotos
                        foreach (DataRow row in result.Tables[1].Rows)
                        {
                            if (System.IO.File.Exists(directorioFisico + "\\" + (string)row["nombreArchivo"]))
                            {
                                File.Delete(directorioFisico + "\\" + (string)row["nombreArchivo"]);
                            }

                            if (System.IO.File.Exists(directorioFisico + "\\small_" + (string)row["nombreArchivo"]))
                            {
                                File.Delete(directorioFisico + "\\small_" + (string)row["nombreArchivo"]);
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ret.success = false;
            ret.message = ex.Message;
        }

        return(ret);
    }
Esempio n. 27
0
        /// <summary>
        /// Destroys all registered external data, full cleanup for internal data.
        /// </summary>
        public void Dispose()
        {
#if DEBUG
            if (_isDisposed)
            {
                throw new Exception("EcsSystems instance already disposed");
            }
            if (!_inited)
            {
                throw new Exception("EcsSystems instance was not initialized");
            }
            _isDisposed = true;
            for (var i = _debugListeners.Count - 1; i >= 0; i--)
            {
                _debugListeners[i].OnSystemsDestroyed();
            }
            _debugListeners.Clear();
            DisabledInDebugSystems.Clear();
            _inited = false;
#endif
            for (var i = _initSystemsCount - 1; i >= 0; i--)
            {
                _initSystems[i].Destroy();
                _initSystems[i] = null;
                _supervisor.ProcessDelayedUpdates();
            }
            _initSystemsCount = 0;

            for (var i = _preInitSystemsCount - 1; i >= 0; i--)
            {
                _preInitSystems[i].PreDestroy();
                _preInitSystems[i] = null;
                _supervisor.ProcessDelayedUpdates();
            }
            _preInitSystemsCount = 0;

            for (var i = _runSystemsCount - 1; i >= 0; i--)
            {
                _runSystems[i] = null;
            }
            _runSystemsCount = 0;

#if !ECP_DISABLE_INJECT
            for (var i = _injectSystemsCount - 1; i >= 0; i--)
            {
                _injectSystems[i] = null;
            }
            _injectSystemsCount = 0;
            _injections.Clear();
#endif
        }
Esempio n. 28
0
 public object OnClearBuff(params object[] objs)
 {
     foreach (ushort k in buffs.Keys)
     {
         SkillBuff buff = buffs[k];
         foreach (GameObject obj in buff.buffs)
         {
             obj.AddComponent <DestoryObject>();
         }
     }
     Owner.property.lockOpera = false;
     buffs.Clear();
     return(null);
 }
Esempio n. 29
0
    public static string deleteImage(int idUser, int idProduct, int idImage)
    {
        string errorMessage = string.Empty;
        Dictionary <string, object> parameters = new System.Collections.Generic.Dictionary <string, object>();

        parameters.Add("idUser", idUser);
        string carpeta = string.Empty;

        //revisar en BD si el cliente tiene carpeta

        carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
        if (!String.IsNullOrEmpty(carpeta))
        {
            string PathDocs         = ConfigurationManager.AppSettings["EmpresasFiles"];
            string inicio           = HttpContext.Current.Server.MapPath(PathDocs);
            string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;

            parameters.Clear();
            parameters.Add("idUser", idUser);
            parameters.Add("idProducto", idProduct);
            parameters.Add("idImagen", idImage);
            string result = string.Empty;
            try
            {
                result = DataAccess.executeStoreProcedureString("Spr_delete_image", parameters);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            string filename = result;

            Common.makeDirectoryIfNotExists(directorioFisico);
            //si existe, borra el que habia
            if (System.IO.File.Exists(directorioFisico + "\\" + filename))
            {
                File.Delete(directorioFisico + "\\" + filename);
            }

            if (System.IO.File.Exists(directorioFisico + "\\small_" + filename))
            {
                File.Delete(directorioFisico + "\\small_" + filename);
            }
        }

        return("{ \"success\": " + (string.IsNullOrEmpty(errorMessage) ? "true" : "false") + ", \"idImage\": " + idImage + " , \"message\": \"" + errorMessage + " \" }");
    }
 internal void Clear()
 {
     trapStartIndex = 0;
     rootObject     = null;
     if (underlyingList != null)
     {
         underlyingList.Clear();
     }
     if (stringKeys != null)
     {
         stringKeys.Clear();
     }
     if (objectKeys != null)
     {
         objectKeys.Clear();
     }
 }
Esempio n. 31
0
    public static string deleteImage(int idUser, int idProduct, int idImage)
    {
        string errorMessage = string.Empty;
        Dictionary<string, object> parameters = new System.Collections.Generic.Dictionary<string, object>();
        parameters.Add("idUser", idUser);
        string carpeta = string.Empty;
        //revisar en BD si el cliente tiene carpeta

        carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
        if (!String.IsNullOrEmpty(carpeta))
        {
            string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
            string inicio = HttpContext.Current.Server.MapPath(PathDocs);
            string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;

            parameters.Clear();
            parameters.Add("idUser", idUser);
            parameters.Add("idProducto", idProduct);
            parameters.Add("idImagen", idImage);
            string result = string.Empty;
            try
            {
                result = DataAccess.executeStoreProcedureString("Spr_delete_image", parameters);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            string filename = result;

            Common.makeDirectoryIfNotExists(directorioFisico);
            //si existe, borra el que habia
            if (System.IO.File.Exists(directorioFisico + "\\" + filename))
                File.Delete(directorioFisico + "\\" + filename);

            if (System.IO.File.Exists(directorioFisico + "\\small_" + filename))
                File.Delete(directorioFisico + "\\small_" + filename);
        }

        return "{ \"success\": " + (string.IsNullOrEmpty(errorMessage) ? "true" : "false") + ", \"idImage\": " + idImage + " , \"message\": \"" + errorMessage + " \" }";
    }
Esempio n. 32
0
    public static GenericResponse deleteProduct(int idUser, int idProduct)
    {
        GenericResponse ret = new GenericResponse();

        Dictionary<string, object> parameters = new System.Collections.Generic.Dictionary<string, object>();
        parameters.Add("idUser", idUser);
        parameters.Add("idProducto", idProduct);
        DataSet result;
        try
        {
            result = DataAccess.executeStoreProcedureDataSet("Spr_delete_product", parameters);
            if (null != result)
            {
                //Verificando respuesta
                if ((int)result.Tables[0].Rows[0]["Success"] == 1)
                {
                    string carpeta = string.Empty;
                    parameters.Clear();
                    parameters.Add("idUser", idUser);
                    carpeta = DataAccess.executeStoreProcedureString("spr_Get_InfoLogo", parameters);
                    if (!String.IsNullOrEmpty(carpeta))
                    {
                        string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
                        string inicio = HttpContext.Current.Server.MapPath( PathDocs );
                        string directorioFisico = inicio + carpeta + "\\products\\" + idProduct;
                        //Si ok Eliminando fotos
                        foreach ( DataRow row in result.Tables[1].Rows )
                        {
                            if (System.IO.File.Exists(directorioFisico + "\\" + (string)row["nombreArchivo"] ))
                                File.Delete(directorioFisico + "\\" + (string)row["nombreArchivo"]);

                            if (System.IO.File.Exists(directorioFisico + "\\small_" + (string)row["nombreArchivo"]))
                                File.Delete(directorioFisico + "\\small_" + (string)row["nombreArchivo"]);
                        }

                    }
                }
            }
        }
        catch (Exception ex)
        {
            ret.success = false;
            ret.message = ex.Message;
        }

        return ret;
    }
Esempio n. 33
0
    private string saveImage()
    {
        string ret = string.Empty;
        string filename = string.Empty;
        try
        {
            if ( Request.Files.Count > 0 )
            {
                var file = Request.Files[0];

                Dictionary< string, object > parameters = new System.Collections.Generic.Dictionary< string, object >();
                parameters.Add( "idUser", HttpContext.Current.Session["findOut"].ToString() );
                string carpeta = string.Empty;
                //revisar en BD si el cliente tiene carpeta

                carpeta = DataAccess.executeStoreProcedureString( "spr_Get_InfoLogo", parameters );

                //ver si tiene carpeta
                if ( !String.IsNullOrEmpty( carpeta ) )
                {
                    //buscar el directorio
                    string PathDocs = ConfigurationManager.AppSettings["EmpresasFiles"];
                    string inicio = HttpContext.Current.Server.MapPath( PathDocs );
                    string directorioFisico = inicio + carpeta + "\\products\\" + Request.Form["idProduct"];
                    //string directorioVirtual = ConfigurationManager.AppSettings["EmpresasFiles"];
                    //string extension = System.IO.Path.GetExtension(Request.Files[0].FileName);

                    filename = file.FileName;

                    Common.makeDirectoryIfNotExists( directorioFisico );
                    //si existe, borra el que habia
                    if ( System.IO.File.Exists( directorioFisico + "\\" + filename ) )
                        File.Delete( directorioFisico + "\\" + filename );

                    if ( System.IO.File.Exists( directorioFisico + "\\small_" + filename ) )
                        File.Delete( directorioFisico + "\\small_" + filename );

                    //cambiar tamaño
                    System.Drawing.Image originalImage =
                                System.Drawing.Image.FromStream( file.InputStream, true, true );
                    //logo grande
                    System.Drawing.Image resizedImage = originalImage.GetThumbnailImage( 160, 160, null, IntPtr.Zero );
                    //logo chico
                    System.Drawing.Image resizedImageCh = originalImage.GetThumbnailImage( 50, 50, null, IntPtr.Zero );

                    //guarda el nuevo
                    //Request.Files[0].SaveAs(Server.MapPath(directorioVirtual) + carpeta + "\\logo.png" );
                    resizedImage.Save( directorioFisico + "\\" + filename );
                    resizedImageCh.Save( directorioFisico + "\\small_" + filename );

                    parameters.Clear();
                    parameters.Add( "idUser", HttpContext.Current.Session["findOut"].ToString() );
                    parameters.Add( "idProducto", Request.Form["idProduct"] );
                    parameters.Add( "idImagen", Request.Form["idImage"] );
                    parameters.Add( "nombreArchivo", filename );
                    int result = 0;
                    try
                    {
                        result = DataAccess.executeStoreProcedureGetInt( "Spr_insert_image", parameters );
                    }
                    catch ( Exception ex )
                    {

                    }
                    if (result > 0)
                    {
                        ret = "{\"success\": true, \"message\": \"\", \"attr\": {\"idImage\": " + result + " , \"fileName\": \"" +
                  filename + "\"}}";
                    }
                    else
                    {
                        ret = "{\"success\": false, \"message\": \"Error al guardar los datos\"}";
                    }
                }

            }
            /*ret = "{\"success\": true, \"message\": \"\", \"attr\": {\"idProductImage\": " + 56 + " , \"name\": \"" +
                  filename + "\"}}";*/
        }
        catch ( Exception ex )
        {
            ret = "{\"success\": false, \"message\": \"" + ex.Message + "\"}";
        }

        return ret;
    }